rbmqmsgque 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 rbmqmsgque protocoll and build together a flat-like structure.

The GOAL for this setup is:

CODE server

#+
#:   @file         example/ruby/perfserver.rb
#:   @brief        perfserver.rb - 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>
#:

require "rbmqmsgque"
include PyMsgque::MkKernel
include PyMsgque::MqMsgque

class PerfServer < MqContextC

  # factory startup
  def initialize()
    super()
    ConfigSetServerSetup(method(:ServerSetup))
  end

  def ECOU
    SendSTART()
    SendU(ReadU())
    SendRETURN()
  end

  def ECOI
    SendSTART()
    SendI(ReadI())
    SendRETURN()
  end

  def ECUL
    SendSTART()
    SendY(ReadY())
    SendS(ReadS())
    SendI(ReadI())
    SendD(ReadD())
    ProxyItem(self)
    SendRETURN()
  end

  def RDUL
    ReadY()
    ReadS()
    ReadI()
    ReadD()
    ReadU()
  end

  def RDUC
    ReadC()
    ReadC()
    ReadC()
    ReadC()
    ReadC()
  end

  def STDB
    SendSTART()
    StorageOpen(ReadC())
    SendRETURN()
  end

  def STDC
    SendSTART()
    StorageClose()
    SendRETURN()
  end

  # [BufferStream-Create-TLS]
  def BUST
    bus = MkBufferStreamC.CreateTLS(0)
    while ReadItemExists()
      bus.WriteU(ReadU())
    end
    bus.PosToStart()
    SendSTART()
    while bus.ReadItemExists()
      SendU(bus.ReadU())
    end
    SendRETURN()
  end
  # [BufferStream-Create-TLS]

  # [BufferList-Create-TLS]
  def BFLT
    bfl = MkBufferListC.CreateTLS(0)
    while ReadItemExists()
      bfl.AppendU(ReadU())
    end
    SendSTART()
    for i in 0...bfl.Size()
      SendU(bfl.IndexGet(i))
    end
    SendRETURN()
  end
  # [BufferList-Create-TLS]

  def BINT
    ReadB()
  end

  def STRT
    ReadC()
  end

  def ServerSetup
    ServiceCreate("ECOU",method(:ECOU))
    ServiceCreate("ECOI",method(:ECOI))
    ServiceCreate("ECUL",method(:ECUL))
    ServiceCreate("RDUL",method(:RDUL))
    ServiceCreate("RDUC",method(:RDUC))
    ServiceCreate("STDB",method(:STDB))
    ServiceCreate("STDC",method(:STDC))
    ServiceCreate("BUST",method(:BUST))
    ServiceCreate("BFLT",method(:BFLT))
    ServiceCreate("BINT",method(:BINT))
    ServiceCreate("STRT",method(:STRT))
  end
end

# ====================================================
# the code below is the "package-main"

# setup commandline arguments for later use
largv = MkBufferListC.CreateLA(ARGV)

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

# inspect commandline-argument for the "factory" to choose... and create a new instance
srv = MqFactoryC.GetCalledL(largv).New()

begin
  srv.LinkCreate(largv)
  srv.ProcessEvent(MqWaitOnEventE::FOREVER)
rescue Exception => ex
  srv.ErrorCatch(ex)
ensure
  srv.Exit()
end