theLink 10.0
Loading...
Searching...
No Matches
MqContextC_Service_PY_API

MqContextC - create and manage a service … More...

+ Collaboration diagram for MqContextC_Service_PY_API:

Functions

static OT_ProcRet pymqmsgque_MqContextC_ServiceCreate (MqContextC_ARGS)
  Python: ctx.ServiceCreate(token:string[4], callback:callable) C-API
create a link between a service-token and a service-callback
 
static OT_ProcRet pymqmsgque_MqContextC_ServiceDelete (MqContextC_ARGS)
  Python: ctx.ServiceDelete(token:string[4]) C-API
delete a service. …
 
static OT_ProcRet pymqmsgque_MqContextC_ServiceIsTransaction (MqContextC_ARGS)
  Python: bool ctx.ServiceIsTransaction() C-API
check if the ongoing-service-call belongs to a transaction …
 
static OT_ProcRet pymqmsgque_MqContextC_ServiceProxy (MqContextC_ARGS)
  Python: ctx.ServiceProxy(token:string[4], ?id:MqSlaveE|int32=MQ_SLAVE_OTHER?) C-API
create a service to link a master-context with a slave-context. …
 
static OT_ProcRet pymqmsgque_MqContextC_ServiceProxyCtx (MqContextC_ARGS)
  Python: ctx.ServiceProxyCtx(token:string[4], target:MqContextC) C-API
same as MqServiceProxy but use an MqContextC as input.
 
static OT_ProcRet pymqmsgque_MqContextC_ServiceProxyCtxExists (MqContextC_ARGS)
  Python: bool ctx.ServiceProxyCtxExists(token:string[4], target:MqContextC) C-API
check if service who belongs to token is a proxy-service
 
static OT_ProcRet pymqmsgque_MqContextC_ServiceProxyRoundRobin (MqContextC_ARGS)
  Python: ctx.ServiceProxyRoundRobin(token:string[4], ident:string) C-API
create a proxy-service using Round-Robin as load-balancer …
 
static OT_ProcRet pymqmsgque_MqContextC_ServiceStorage (MqContextC_ARGS)
  Python: ctx.ServiceStorage(token:string[4]) C-API
setup a service listen on a MqContextC_ServiceApi_Identifer and save all read-data-package into the STORAGE
 
static OT_ProcRet pymqmsgque_MqContextC_ServiceTokenCheck (MqContextC_ARGS)
  Python: bool ctx.ServiceTokenCheck(token:string[4]) C-API
in an ongoing-service-call check if the current MqContextC_ServiceApi_Identifer is token
 
static OT_ProcRet pymqmsgque_MqContextC_ServiceTokenExists (MqContextC_ARGS)
  Python: bool ctx.ServiceTokenExists(token:string[4]) C-API
check if the MqContextC_ServiceApi_Identifer token is defined as ctx service …
 
static OT_ProcRet pymqmsgque_MqContextC_ServiceTokenGet (MqContextC_ARGS)
  Python: string[4] ctx.ServiceTokenGet() C-API
in an ongoing-service-call get the current MqContextC_ServiceApi_Identifer
 

Detailed Description

MqContextC - create and manage a service …

To provide a service is the main purpose of a server and the main-purpose of a client/server connection is to call a service and to process the result.
A service can be defined on the server or on the client. On the server a service can be initial setup with MqServerSetupIF method and finally cleanup with MqServerCleanupIF.

‍A service is created with the MqServiceCreate and deleted with the MqServiceDelete.

A service can be created and deleted during the entire life-cycle of the server or the client. If the server/client-context is deleted all services of the are deleted also.

‍A MqServiceDelete is not required.

Creating or deleting a service is like granting or revoking the right to access a single feature.

eventloop

To receive a data-package on a service the event-loop have to be active. The event-loop ia always active on an synchronous-service-call . On a server the event-loop is started with MqProcessEvent at startup.
synchronous-service-call
A synchronous-service-call always block and enter the event-loop to wait for an answer
asynchronous-service-call
A asynchronous-service-call always return immediately and the possible result is received on a callback

callback

A callback is the function called by a service and required to receive data from remote.
A callback is created with MqServiceCreate or is part of the service-call.
A callback can be a service-identifer or a service-callback.
service-call with callback
SendEND_AND_CALLBACK, SendEND_AND_SUB, SendEND_AND_TRANSACTION
service-call without callback
SendEND, SendEND_AND_WAIT

Example from MyServer.py define the service HLWO on the server-link-setup

import sys
from pymqmsgque import *

# package-item
class MyServer(MqContextC):

  # factory startup
  def __init__(self, tmpl=None):
    self.ConfigSetServerSetup(self.ServerSetup)
    super().__init__(tmpl)

  # service to serve all incoming requests for token "HLWO"
  def MyFirstService(self):
    self.SendSTART()
    self.SendSTR(self.ReadSTR() + " World")
    self.SendRETURN()

  # define a service as link between the token "HLWO" and the callback "MyFirstService"
  def ServerSetup(self):
    self.ServiceCreate("HLWO",self.MyFirstService)

# package-main
if __name__ == "__main__":

  # create the "MyServer" factory… and the object
  srv = MqFactoryC.Add(MyServer).New()

  try:
    srv.LinkCreate(sys.argv)
    srv.ProcessEvent(MqWaitOnEventE.FOREVER)
  except Exception as ex:
    srv.ErrorCatch(ex)
  finally:
    srv.Exit()

Function Documentation

◆ pymqmsgque_MqContextC_ServiceCreate()

static OT_ProcRet pymqmsgque_MqContextC_ServiceCreate ( MqContextC_ARGS )
static

Python: ctx.ServiceCreate(token:string[4], callback:callable) C-API
create a link between a service-token and a service-callback

Definition at line 3012 of file MqContextC_py.c.

3012 {
3015 MQ_TOK token = 0;
3017 OT_SETUP_CALLABLE(callback)
3020 MkErrorC_Check(hdl,MqServiceCreate (hdl, token, NS(ServiceCall), callback, NS(ServiceFree), NULL));
3022 goto end;
3023 error:
3025 end:
3026 OT_CLEANUP_CALLABLE(callback)
3028}
#define OT_SETUP_VARARGS(min, max, d)
#define OT_retObj_SET_Error
#define OT_CHECK_REQUIRED(val)
#define OT_retObj_SET_None
#define OT_retObj_RETURN
#define OT_CHECK_NOARGS
#define MkErrorC_Check(mng, PROC)
#define OT_CHECK_STRN(val)
#define NS(n)
#define OT_SETUP_hdl
#define ServiceCreate_doc
#define error
Definition high_lng.h:339
#define MqServiceCreate(...)
MK_STRN MQ_TOK
MqContextC - a char[4+1] or hex[8+1] string used to unique identify a service …
MK_STRB token[9]
Definition high_lng.h:229
#define OT_CHECK_CALLABLE(val)
#define OT_CLEANUP_CALLABLE(val)
#define OT_SETUP_CALLABLE(val)

◆ pymqmsgque_MqContextC_ServiceDelete()

static OT_ProcRet pymqmsgque_MqContextC_ServiceDelete ( MqContextC_ARGS )
static

Python: ctx.ServiceDelete(token:string[4]) C-API
delete a service. …

Definition at line 3031 of file MqContextC_py.c.

3031 {
3034 MQ_TOK token = 0;
3039 goto end;
3040 error:
3042 end:
3044}
#define OT_SETUP_ONEARG(d)
#define ServiceDelete_doc
#define MqServiceDelete(...)

◆ pymqmsgque_MqContextC_ServiceIsTransaction()

static OT_ProcRet pymqmsgque_MqContextC_ServiceIsTransaction ( MqContextC_ARGS )
static

Python: bool ctx.ServiceIsTransaction() C-API
check if the ongoing-service-call belongs to a transaction …

Definition at line 3047 of file MqContextC_py.c.

3047 {
3052 goto end;
3053 error:
3055 end:
3057}
#define OT_retObj_SET_BOL(nat)
#define OT_SETUP_NOARG(d)
#define ServiceIsTransaction_doc
static bool MqServiceIsTransaction(MQ_CTX const ctx)
check if the ongoing-service-call belongs to a transaction …

◆ pymqmsgque_MqContextC_ServiceProxy()

static OT_ProcRet pymqmsgque_MqContextC_ServiceProxy ( MqContextC_ARGS )
static

Python: ctx.ServiceProxy(token:string[4], ?id:MqSlaveE|int32=MQ_SLAVE_OTHER?) C-API
create a service to link a master-context with a slave-context. …

Definition at line 3060 of file MqContextC_py.c.

3060 {
3063 MQ_TOK token = 0;
3068 MkErrorC_Check(hdl,MqServiceProxy (hdl, token, id));
3070 goto end;
3071 error:
3073 end:
3075}
#define OT_CHECK_OPTIONAL(val)
#define ServiceProxy_doc
#define MqServiceProxy(...)
@ MQ_SLAVE_OTHER
internal: on the master-ctx get the slave-ctx and on the slave-ctx get the master-ctx
MK_NUM MQ_SLAVE_ID
a slave identiver
#define OT_CHECK_SLAVE_ID(val)

◆ pymqmsgque_MqContextC_ServiceProxyCtx()

static OT_ProcRet pymqmsgque_MqContextC_ServiceProxyCtx ( MqContextC_ARGS )
static

Python: ctx.ServiceProxyCtx(token:string[4], target:MqContextC) C-API
same as MqServiceProxy but use an MqContextC as input.

Definition at line 3078 of file MqContextC_py.c.

3078 {
3081 MQ_TOK token = 0;
3083 MQ_CTX target = 0;
3086 MkErrorC_Check(hdl,MqServiceProxyCtx (hdl, token, target));
3088 goto end;
3089 error:
3091 end:
3093}
#define ServiceProxyCtx_doc
#define MK_NULL_NO
#define MqServiceProxyCtx(...)
#define OT_CHECK_CTX(val, nullB)
PUBLIC data structure for the pymqmsgque-specific-data

◆ pymqmsgque_MqContextC_ServiceProxyCtxExists()

static OT_ProcRet pymqmsgque_MqContextC_ServiceProxyCtxExists ( MqContextC_ARGS )
static

Python: bool ctx.ServiceProxyCtxExists(token:string[4], target:MqContextC) C-API
check if service who belongs to token is a proxy-service

Definition at line 3096 of file MqContextC_py.c.

3096 {
3099 MQ_TOK token = 0;
3101 MQ_CTX target = 0;
3105 goto end;
3106 error:
3108 end:
3110}
#define ServiceProxyCtxExists_doc
bool MqServiceProxyCtxExists(MQ_CTX const ctx, MQ_TOK const token, MQ_CTX const target)
check if service who belongs to token is a proxy-service

◆ pymqmsgque_MqContextC_ServiceProxyRoundRobin()

static OT_ProcRet pymqmsgque_MqContextC_ServiceProxyRoundRobin ( MqContextC_ARGS )
static

Python: ctx.ServiceProxyRoundRobin(token:string[4], ident:string) C-API
create a proxy-service using Round-Robin as load-balancer …

Definition at line 3113 of file MqContextC_py.c.

3113 {
3116 MQ_TOK token = 0;
3118 MK_STRN ident = 0;
3123 goto end;
3124 error:
3126 end:
3128}
#define ServiceProxyRoundRobin_doc
const MK_STRB * MK_STRN
#define MqServiceProxyRoundRobin(...)

◆ pymqmsgque_MqContextC_ServiceStorage()

static OT_ProcRet pymqmsgque_MqContextC_ServiceStorage ( MqContextC_ARGS )
static

Python: ctx.ServiceStorage(token:string[4]) C-API
setup a service listen on a MqContextC_ServiceApi_Identifer and save all read-data-package into the STORAGE

Definition at line 3131 of file MqContextC_py.c.

3131 {
3134 MQ_TOK token = 0;
3139 goto end;
3140 error:
3142 end:
3144}
#define ServiceStorage_doc
#define MqServiceStorage(...)

◆ pymqmsgque_MqContextC_ServiceTokenCheck()

static OT_ProcRet pymqmsgque_MqContextC_ServiceTokenCheck ( MqContextC_ARGS )
static

Python: bool ctx.ServiceTokenCheck(token:string[4]) C-API
in an ongoing-service-call check if the current MqContextC_ServiceApi_Identifer is token

Definition at line 3147 of file MqContextC_py.c.

3147 {
3150 MQ_TOK token = 0;
3154 goto end;
3155 error:
3157 end:
3159}
#define ServiceTokenCheck_doc
bool MqServiceTokenCheck(MQ_CTX const ctx, MQ_TOK const token)
in an ongoing-service-call check if the current MqContextC_ServiceApi_Identifer is token …

◆ pymqmsgque_MqContextC_ServiceTokenExists()

static OT_ProcRet pymqmsgque_MqContextC_ServiceTokenExists ( MqContextC_ARGS )
static

Python: bool ctx.ServiceTokenExists(token:string[4]) C-API
check if the MqContextC_ServiceApi_Identifer token is defined as ctx service …

Definition at line 3162 of file MqContextC_py.c.

3162 {
3165 MQ_TOK token = 0;
3169 goto end;
3170 error:
3172 end:
3174}
#define ServiceTokenExists_doc
bool MqServiceTokenExists(MQ_CTX const ctx, MQ_TOK const token)
check if the MqContextC_ServiceApi_Identifer token is defined as ctx service …

◆ pymqmsgque_MqContextC_ServiceTokenGet()

static OT_ProcRet pymqmsgque_MqContextC_ServiceTokenGet ( MqContextC_ARGS )
static

Python: string[4] ctx.ServiceTokenGet() C-API
in an ongoing-service-call get the current MqContextC_ServiceApi_Identifer

Definition at line 3177 of file MqContextC_py.c.

3177 {
3182 goto end;
3183 error:
3185 end:
3187}
#define OT_retObj_SET_STR(nat)
#define ServiceTokenGet_doc
MQ_TOK MqServiceTokenGet(MQ_CTX const ctx)
in an ongoing-service-call get the current MqContextC_ServiceApi_Identifer …