theLink 10.0 NHI1 - theKernel - theLink - theConfig - theSq3Lite - theCompiler - theBrain - theGuard
c - tcl - py - rb - jv - cc
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 py_mqmsgque_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 py_mqmsgque_MqContextC_ServiceDelete (MqContextC_ARGS)
  Python: ctx.ServiceDelete(token:string[4]) C-API
delete a service. …
 
static OT_ProcRet py_mqmsgque_MqContextC_ServiceIsTransaction (MqContextC_ARGS)
  Python: bool ctx.ServiceIsTransaction() C-API
check if the ongoing-service-call belongs to a transaction …
 
static OT_ProcRet py_mqmsgque_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 py_mqmsgque_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 py_mqmsgque_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 py_mqmsgque_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 py_mqmsgque_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 py_mqmsgque_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 py_mqmsgque_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 py_mqmsgque_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 IServerSetup method and finally cleanup with IServerCleanup.

‍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 SRV1 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

◆ py_mqmsgque_MqContextC_ServiceCreate()

static OT_ProcRet py_mqmsgque_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 3010 of file MqContextC_py.c.

3010 {
3012 OT_SETUP_VARARGS(2,2,ServiceCreate_doc)
3013 MQ_TOK token = 0;
3014 OT_CHECK_REQUIRED(OT_CHECK_STRN (token))
3015 OT_SETUP_CALLABLE(callback)
3016 OT_CHECK_REQUIRED(OT_CHECK_CALLABLE(callback))
3017 OT_CHECK_NOARGS
3018 MkErrorC_Check(hdl,MqServiceCreate (hdl, token, NS(ServiceCall), callback, NS(ServiceFree), NULL));
3019 OT_retObj_SET_None
3020 goto end;
3021 error:
3022 OT_retObj_SET_Error
3023 end:
3024 OT_CLEANUP_CALLABLE(callback)
3026}
#define OT_SETUP_hdl
#define ServiceCreate_doc
#define OT_retObj_RETURN
#define error
#define MqServiceCreate(...)
MK_STRN MQ_TOK
MqContextC - a char[4+1] or hex[8+1] string used to unique identify a service …

◆ py_mqmsgque_MqContextC_ServiceDelete()

static OT_ProcRet py_mqmsgque_MqContextC_ServiceDelete ( MqContextC_ARGS )
static

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

Definition at line 3029 of file MqContextC_py.c.

3029 {
3031 OT_SETUP_ONEARG(ServiceDelete_doc)
3032 MQ_TOK token = 0;
3033 OT_CHECK_REQUIRED(OT_CHECK_STRN (token))
3034 OT_CHECK_NOARGS
3035 MkErrorC_Check(hdl,MqServiceDelete (hdl, token));
3036 OT_retObj_SET_None
3037 goto end;
3038 error:
3039 OT_retObj_SET_Error
3040 end:
3042}
#define ServiceDelete_doc
#define MqServiceDelete(...)

◆ py_mqmsgque_MqContextC_ServiceIsTransaction()

static OT_ProcRet py_mqmsgque_MqContextC_ServiceIsTransaction ( MqContextC_ARGS )
static

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

Definition at line 3045 of file MqContextC_py.c.

3045 {
3047 OT_SETUP_NOARG(ServiceIsTransaction_doc)
3048 OT_CHECK_NOARGS
3049 OT_retObj_SET_BOL(MqServiceIsTransaction (hdl))
3050 goto end;
3051 error:
3052 OT_retObj_SET_Error
3053 end:
3055}
#define ServiceIsTransaction_doc
bool MqServiceIsTransaction(MQ_CTX const ctx)
check if the ongoing-service-call belongs to a transaction …

◆ py_mqmsgque_MqContextC_ServiceProxy()

static OT_ProcRet py_mqmsgque_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 3058 of file MqContextC_py.c.

3058 {
3060 OT_SETUP_VARARGS(1,2,ServiceProxy_doc)
3061 MQ_TOK token = 0;
3062 OT_CHECK_REQUIRED(OT_CHECK_STRN (token))
3064 OT_CHECK_OPTIONAL(OT_CHECK_SLAVE_ID (id))
3065 OT_CHECK_NOARGS
3066 MkErrorC_Check(hdl,MqServiceProxy (hdl, token, id));
3067 OT_retObj_SET_None
3068 goto end;
3069 error:
3070 OT_retObj_SET_Error
3071 end:
3073}
#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

◆ py_mqmsgque_MqContextC_ServiceProxyCtx()

static OT_ProcRet py_mqmsgque_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 3076 of file MqContextC_py.c.

3076 {
3078 OT_SETUP_VARARGS(2,2,ServiceProxyCtx_doc)
3079 MQ_TOK token = 0;
3080 OT_CHECK_REQUIRED(OT_CHECK_STRN (token))
3081 MQ_CTX target = 0;
3082 OT_CHECK_REQUIRED(OT_CHECK_CTX (target,MK_NULL_NO))
3083 OT_CHECK_NOARGS
3084 MkErrorC_Check(hdl,MqServiceProxyCtx (hdl, token, target));
3085 OT_retObj_SET_None
3086 goto end;
3087 error:
3088 OT_retObj_SET_Error
3089 end:
3091}
#define ServiceProxyCtx_doc
#define MK_NULL_NO
#define MqServiceProxyCtx(...)
PUBLIC data structure for the pymqmsgque-specific-data

◆ py_mqmsgque_MqContextC_ServiceProxyCtxExists()

static OT_ProcRet py_mqmsgque_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 3094 of file MqContextC_py.c.

3094 {
3096 OT_SETUP_VARARGS(2,2,ServiceProxyCtxExists_doc)
3097 MQ_TOK token = 0;
3098 OT_CHECK_REQUIRED(OT_CHECK_STRN (token))
3099 MQ_CTX target = 0;
3100 OT_CHECK_REQUIRED(OT_CHECK_CTX (target,MK_NULL_NO))
3101 OT_CHECK_NOARGS
3102 OT_retObj_SET_BOL(MqServiceProxyCtxExists (hdl, token, target))
3103 goto end;
3104 error:
3105 OT_retObj_SET_Error
3106 end:
3108}
#define ServiceProxyCtxExists_doc
MQ_EXTERN 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

◆ py_mqmsgque_MqContextC_ServiceProxyRoundRobin()

static OT_ProcRet py_mqmsgque_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 3111 of file MqContextC_py.c.

3111 {
3113 OT_SETUP_VARARGS(2,2,ServiceProxyRoundRobin_doc)
3114 MQ_TOK token = 0;
3115 OT_CHECK_REQUIRED(OT_CHECK_STRN (token))
3116 MK_STRN ident = 0;
3117 OT_CHECK_REQUIRED(OT_CHECK_STRN (ident))
3118 OT_CHECK_NOARGS
3119 MkErrorC_Check(hdl,MqServiceProxyRoundRobin (hdl, token, ident));
3120 OT_retObj_SET_None
3121 goto end;
3122 error:
3123 OT_retObj_SET_Error
3124 end:
3126}
#define ServiceProxyRoundRobin_doc
const MK_STRB * MK_STRN
#define MqServiceProxyRoundRobin(...)

◆ py_mqmsgque_MqContextC_ServiceStorage()

static OT_ProcRet py_mqmsgque_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 3129 of file MqContextC_py.c.

3129 {
3131 OT_SETUP_ONEARG(ServiceStorage_doc)
3132 MQ_TOK token = 0;
3133 OT_CHECK_REQUIRED(OT_CHECK_STRN (token))
3134 OT_CHECK_NOARGS
3135 MkErrorC_Check(hdl,MqServiceStorage (hdl, token));
3136 OT_retObj_SET_None
3137 goto end;
3138 error:
3139 OT_retObj_SET_Error
3140 end:
3142}
#define ServiceStorage_doc
#define MqServiceStorage(...)

◆ py_mqmsgque_MqContextC_ServiceTokenCheck()

static OT_ProcRet py_mqmsgque_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 3145 of file MqContextC_py.c.

3145 {
3147 OT_SETUP_ONEARG(ServiceTokenCheck_doc)
3148 MQ_TOK token = 0;
3149 OT_CHECK_REQUIRED(OT_CHECK_STRN (token))
3150 OT_CHECK_NOARGS
3151 OT_retObj_SET_BOL(MqServiceTokenCheck (hdl, token))
3152 goto end;
3153 error:
3154 OT_retObj_SET_Error
3155 end:
3157}
#define ServiceTokenCheck_doc
MQ_EXTERN bool MqServiceTokenCheck(MQ_CTX const ctx, MQ_TOK const token)
in an ongoing-service-call check if the current MqContextC_ServiceApi_Identifer is token …

◆ py_mqmsgque_MqContextC_ServiceTokenExists()

static OT_ProcRet py_mqmsgque_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 3160 of file MqContextC_py.c.

3160 {
3162 OT_SETUP_ONEARG(ServiceTokenExists_doc)
3163 MQ_TOK token = 0;
3164 OT_CHECK_REQUIRED(OT_CHECK_STRN (token))
3165 OT_CHECK_NOARGS
3166 OT_retObj_SET_BOL(MqServiceTokenExists (hdl, token))
3167 goto end;
3168 error:
3169 OT_retObj_SET_Error
3170 end:
3172}
#define ServiceTokenExists_doc
MQ_EXTERN bool MqServiceTokenExists(MQ_CTX const ctx, MQ_TOK const token)
check if the MqContextC_ServiceApi_Identifer token is defined as ctx service …

◆ py_mqmsgque_MqContextC_ServiceTokenGet()

static OT_ProcRet py_mqmsgque_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 3175 of file MqContextC_py.c.

3175 {
3177 OT_SETUP_NOARG(ServiceTokenGet_doc)
3178 OT_CHECK_NOARGS
3179 OT_retObj_SET_STR(MqServiceTokenGet (hdl))
3180 goto end;
3181 error:
3182 OT_retObj_SET_Error
3183 end:
3185}
#define ServiceTokenGet_doc
MQ_EXTERN MQ_TOK MqServiceTokenGet(MQ_CTX const ctx)
in an ongoing-service-call get the current MqContextC_ServiceApi_Identifer …