tclmqmsgque 9.0
Loading...
Searching...
No Matches
Example: perfserver

Documentation of the perfserver tool used for example.test.

INTRODUCTION

The perfserver tool is used server-part of the performance-test

To perform the test the perfclient send various service request to the perfserver. The perfclient is written in C and finally create a report.

All context created, are connected using the tclmqmsgque protocoll and build together a flat-like structure.

The GOAL for this setup is:

CODE server

#!/usr/bin/env tclsh
#+
#:   @file         example/tcl/perfserver.tcl
#:   @brief        perfserver.tcl - 03 May 2023 - aotto1968
#:   @copyright    (C) NHI - #1 - Project - Group
#:                 This software has NO permissions to copy,
#:                 please contact AUTHOR for additional information
#:   @version      1c3a8f89f6bbd5c146252125f8a426400f6e1300
#:   @date         Wed May 3 12:28:13 2023 +0200
#:   @author       aotto1968 <aotto1968@t-online.de>
#:

package require tclmsgque::MqMsgque
namespace import tclmsgque::MqMsgque::*
namespace import tclmsgque::MkKernel::*

::oo::class create perfserver {
  superclass MqContextC

  method Ot_ECOU {} {
    my SendSTART
    my SendU [my ReadU]
    my SendRETURN
  }

  method Ot_ECOI {} {
    my SendSTART
    my SendI [my ReadI]
    my SendRETURN
  }

  method Ot_ECUL {} {
    my SendSTART
    my SendY [my ReadY]
    my SendS [my ReadS]
    my SendI [my ReadI]
    my SendD [my ReadD]
    my ProxyItem [self]
    my SendRETURN
  }

  method Ot_RDUL {} {
    my ReadY
    my ReadS
    my ReadI
    my ReadD
    my ReadB
  }

  method Ot_RDUC {} {
    my ReadC
    my ReadC
    my ReadC
    my ReadC
    my ReadC
  }

  method Ot_STDB {} {
    my SendSTART
    my StorageOpen [my ReadC]
    my SendRETURN
  }

  method Ot_STDC {} {
    my SendSTART
    my StorageClose
    my SendRETURN
  }

  # [BufferStream-Create-TLS]
  method Ot_BUST {} {
    set bus [MkBufferStreamC CreateTLS 0]
    while {[my ReadItemExists]} {
      $bus WriteU [my ReadU]
    }
    $bus PosToStart
    my SendSTART
    while {[$bus ReadItemExists]} {
      my SendU [$bus ReadU]
    }
    my SendRETURN
  }
  # [BufferStream-Create-TLS]

  # [BufferList-Create-TLS]
  method Ot_BFLT {} {
    set bfl [MkBufferListC CreateTLS 0]
    while {[my ReadItemExists]} {
      $bfl AppendU [my ReadU]
    }
    my SendSTART
    for {set i 0} {$i < [$bfl Size]} {incr i} {
      my SendU [$bfl IndexGet $i]
    }
    my SendRETURN
  }
  # [BufferList-Create-TLS]

  method Ot_BINT {} {
    my ReadB
  }

  method Ot_STRT {} {
    my ReadC
  }

  # define a service as link between the token "HLWO" and the callback "MyFirstService"
  method serverSetup {} {
    my ServiceCreate ECOU Ot_ECOU
    my ServiceCreate ECOI Ot_ECOI
    my ServiceCreate ECUL Ot_ECUL
    my ServiceCreate RDUL Ot_RDUL
    my ServiceCreate RDUC Ot_RDUC
    my ServiceCreate STDB Ot_STDB
    my ServiceCreate STDC Ot_STDC
    my ServiceCreate BUST Ot_BUST
    my ServiceCreate BFLT Ot_BFLT
    my ServiceCreate BINT Ot_BINT
    my ServiceCreate STRT Ot_STRT
  }

  # factory startup (constructor)
  constructor {{tmpl ""}} {
    next $tmpl
    my ConfigSetServerSetup serverSetup
  }
} 

tclmsgque::MqMsgque Main {

  # setup commandline arguments for later use
  set largv  [MkBufferListC CreateLA {*}$argv]

  # [factory-item]
  # create "perfserver" factory... and make it to the default.
  [MqFactoryC Add perfserver] Default
  # [factory-item]

  # inspect commandline-argument for the "factory" to choose... and create a new instance
  set srv   [ [MqFactoryC GetCalledL $largv] New ]

  try {
    $srv LinkCreate $largv
    $srv ProcessEvent MQ_WAIT_FOREVER
  } on error {} {
    $srv ErrorCatch
  } finally {
    $srv Exit
  }
}