Loading...
Searching...
No Matches
MqContextC_LinkApi_C_API

MqContextC - setup and manage a client-server-linkMore...

+ Collaboration diagram for MqContextC_LinkApi_C_API:

Data Structures

struct  MqLinkSlaveS
 needed to "run-over-all-slaves" → example: MqRouteGetTree More...
 
struct  MqLinkS
 object responsible to manage a client/server link data More...
 

Functions

MQ_EXTERN enum MkErrorE MqLinkCreate_RT (MK_RT const mkrt, MQ_CTX const ctx, MK_BAC args)
 make ctx to a parent-context and setup a new client-server-link
 
MQ_EXTERN enum MkErrorE MqLinkConnect_RT (MK_RT const mkrt, MQ_CTX const ctx)
 re-connect a client-server-link after a server crash or a network downtime …
 
MQ_EXTERN enum MkErrorE MqLinkShutdown_RT (MK_RT const mkrt, MQ_CTX const ctx)
 shutdown the communication with a server
 
MQ_EXTERN enum MkErrorE MqLinkCreateChild_RT (MK_RT const mkrt, MQ_CTX const ctx, MQ_CTX const parent, MK_BAC const args)
 make a context to a child-context on-top of an existing parent-client-server-link
 
MQ_EXTERN enum MkErrorE MqLinkDefault_RT (MK_RT const mkrt, MQ_CTX const ctx, MK_BAC const args)
 callback as wrapper for MqLinkCreate or MqLinkCreateChild with additional error-check code …
 
MQ_EXTERN void MqLinkDelete_RT (MK_RT const mkrt, MQ_CTX const ctx)
 close the client-server-link
 
MQ_EXTERN bool MqLinkIsConnected (MQ_CTX const ctx) MK_ATTR_HDL
 is the context connected? …
 
MQ_CTX MqLinkGetParent (MQ_CTX const ctx)
 get the initial parent-context from a client/server link …
 
bool MqLinkIsParent (MQ_CTX const ctx)
 is the context a parent-context? …
 
MK_NUM MqLinkGetCtxId (MQ_CTX const ctx)
 get an identifier which is unique per parent-or-child-context
 
MK_STRN MqLinkGetTargetIdent (MQ_CTX const ctx)
 get the ident of the link-target
 

MqContextC - MqContextC_LinkApi_Link_C_API - function

MQ_EXTERN MQ_CTX MqLinkGetParentP (MQ_CTX const ctx)
 Non-inline replacement for MqLinkGetParent
 
MQ_EXTERN MK_NUM MqLinkGetCtxIdP (MQ_CTX const ctx)
 Non-inline replacement for MqLinkGetCtxId
 
MQ_EXTERN MK_STRN MqLinkGetTargetIdentP (MQ_CTX const ctx)
 Non-inline replacement for MqLinkGetTargetIdent
 
MQ_EXTERN MK_BOOL MqLinkIsParentP (MQ_CTX const ctx)
 Non-inline replacement for MqLinkIsParent
 

MqContextC - MqContextC_LinkApi_Link_C_API - overload

#define MqLinkConnect_NULL(...)
 
#define MqLinkConnect(...)
 
#define MqLinkConnect_E(...)
 
#define MqLinkConnect_C(...)
 
#define MqLinkCreate_NULL(...)
 
#define MqLinkCreate(...)
 
#define MqLinkCreate_1(ctx)
 
#define MqLinkCreate_E(...)
 
#define MqLinkCreate_C(...)
 
#define MqLinkCreateChild_NULL(...)
 
#define MqLinkCreateChild(...)
 
#define MqLinkCreateChild_2(ctx, parent)
 
#define MqLinkCreateChild_E(...)
 
#define MqLinkCreateChild_C(...)
 
#define MqLinkDefault_NULL(...)
 
#define MqLinkDefault(...)
 
#define MqLinkDelete_NULL(...)
 
#define MqLinkDelete(...)
 
#define MqLinkShutdown_NULL(...)
 
#define MqLinkShutdown(...)
 
#define MqLinkShutdown_E(...)
 
#define MqLinkShutdown_C(...)
 

Detailed Description

MqContextC - setup and manage a client-server-link

The client-server-link connect two context, a client-parent-context and a server-parent-context. The link can be local (connect two context on the same host) or can be remote (connect two context on different hosts). On-Top the parent-context multiple child-context are allowed.

  !on remote host!                                  !on local host!

      server1---------x                     x----------server2
         |            |                     |             |
         |     child-context-1       child-context-2      |
         |            |                     |             |                      server
 parent-context-1-----x                     x-----parent-context-2
         |                                                |
 (MqConfigS::server)                 (example: MqConfigS::server --fork --uds … --file …)
         |                                                |
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
         |                                                |
      (--tcp)                                  (--pipe, --uds, --tcp)
         |                                                |
 parent-context-1-----x                     x-----parent-context-2
         |            |                     |             |                      client
         |     child-context-1       child-context-2      |
         |            |                     |             |
         x------------x--------client-------x-------------x

                           !on local host!

Definition of a "client-context"

Definition of a "server-context"

client --tcp --host REMOTE_HOST --port REMOTE_PORT ... or
client --uds --file MYFILE ...

Definition of a "parent-context"

Definition of a "child-context"

Macro Definition Documentation

◆ MqLinkConnect

#define MqLinkConnect ( ...)
Value:
#define MK_RT_CALL

Definition at line 219 of file msgque_overload_mq.h.

◆ MqLinkConnect_C

#define MqLinkConnect_C ( ...)
Value:
if (MkErrorCheckI(MqLinkConnect(__VA_ARGS__)))

Definition at line 221 of file msgque_overload_mq.h.

◆ MqLinkConnect_E

#define MqLinkConnect_E ( ...)
Value:
MkErrorCheck(MqLinkConnect(__VA_ARGS__))

Definition at line 220 of file msgque_overload_mq.h.

◆ MqLinkConnect_NULL

#define MqLinkConnect_NULL ( ...)
Value:
#define MK_RT_CALL_NULL

Definition at line 218 of file msgque_overload_mq.h.

◆ MqLinkCreate

#define MqLinkCreate ( ...)
Value:

Definition at line 223 of file msgque_overload_mq.h.

◆ MqLinkCreate_1

#define MqLinkCreate_1 ( ctx)
Value:
MqLinkCreate(ctx,NULL)

Definition at line 224 of file msgque_overload_mq.h.

◆ MqLinkCreate_C

#define MqLinkCreate_C ( ...)
Value:
if (MkErrorCheckI(MqLinkCreate(__VA_ARGS__)))

Definition at line 226 of file msgque_overload_mq.h.

◆ MqLinkCreate_E

#define MqLinkCreate_E ( ...)
Value:
MkErrorCheck(MqLinkCreate(__VA_ARGS__))

Definition at line 225 of file msgque_overload_mq.h.

◆ MqLinkCreate_NULL

#define MqLinkCreate_NULL ( ...)
Value:

Definition at line 222 of file msgque_overload_mq.h.

◆ MqLinkCreateChild

#define MqLinkCreateChild ( ...)
Value:

Definition at line 228 of file msgque_overload_mq.h.

◆ MqLinkCreateChild_2

#define MqLinkCreateChild_2 ( ctx,
parent )
Value:
MqLinkCreateChild(ctx,parent,NULL)

Definition at line 229 of file msgque_overload_mq.h.

◆ MqLinkCreateChild_C

#define MqLinkCreateChild_C ( ...)
Value:
if (MkErrorCheckI(MqLinkCreateChild(__VA_ARGS__)))

Definition at line 231 of file msgque_overload_mq.h.

◆ MqLinkCreateChild_E

#define MqLinkCreateChild_E ( ...)
Value:
MkErrorCheck(MqLinkCreateChild(__VA_ARGS__))

Definition at line 230 of file msgque_overload_mq.h.

◆ MqLinkCreateChild_NULL

#define MqLinkCreateChild_NULL ( ...)
Value:

Definition at line 227 of file msgque_overload_mq.h.

◆ MqLinkDefault

#define MqLinkDefault ( ...)
Value:

Definition at line 233 of file msgque_overload_mq.h.

◆ MqLinkDefault_NULL

#define MqLinkDefault_NULL ( ...)
Value:

Definition at line 232 of file msgque_overload_mq.h.

◆ MqLinkDelete

#define MqLinkDelete ( ...)
Value:

Definition at line 235 of file msgque_overload_mq.h.

◆ MqLinkDelete_NULL

#define MqLinkDelete_NULL ( ...)
Value:

Definition at line 234 of file msgque_overload_mq.h.

◆ MqLinkShutdown

#define MqLinkShutdown ( ...)
Value:

Definition at line 237 of file msgque_overload_mq.h.

◆ MqLinkShutdown_C

#define MqLinkShutdown_C ( ...)
Value:
if (MkErrorCheckI(MqLinkShutdown(__VA_ARGS__)))

Definition at line 239 of file msgque_overload_mq.h.

◆ MqLinkShutdown_E

#define MqLinkShutdown_E ( ...)
Value:
MkErrorCheck(MqLinkShutdown(__VA_ARGS__))

Definition at line 238 of file msgque_overload_mq.h.

◆ MqLinkShutdown_NULL

#define MqLinkShutdown_NULL ( ...)
Value:

Definition at line 236 of file msgque_overload_mq.h.

Function Documentation

◆ MqLinkConnect_RT()

MQ_EXTERN enum MkErrorE MqLinkConnect_RT ( MK_RT const mkrt,
MQ_CTX const ctx )

re-connect a client-server-link after a server crash or a network downtime …

Do nothing if the client-server-link is already connected. This function is only useful in an event-function (IEvent) if the link-disconnect (ErrorIsEXIT) is ignored (ErrorReset). Read more from the: /example/c/Filter4.c example.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]ctxthe MqContextS instance to work on
Returns
The MkErrorE status from the DEFAULT MkErrorC in MkRuntimeS::error_mk

◆ MqLinkCreate_RT()

MQ_EXTERN enum MkErrorE MqLinkCreate_RT ( MK_RT const mkrt,
MQ_CTX const ctx,
MK_BAC args )

make ctx to a parent-context and setup a new client-server-link

The goal of the MqLinkCreate is to setup a link to a new server-context on the SERVER.

The link is created with MqIoComE to a server started with MqStartE.

The argument args is a list of command-line-arguments to configure the client-server-link including the @ item to add server-command-line-arguments.

The following special-keyword as first argument after @ is recognized:

factory-name
A known factory previous added with MqFactoryAdd.
MqFactoryAdd_1("myFeature");
...
MqLinkCreate(ctx,...,"@",myFeature,...);
#define MqFactoryAdd_1(fct)
SELF
Recognized as the initial-factory-name. (e.g. MqFactoryInitial)
The startup with "@ SELF arg1…" will be "@ executable factory-name arg1…"
WORKER
Recognized as the own executable name.
The startup from "@ WORKER arg1…" will be "@ executable arg1…"
If the ctx is not the server-context… (e.g MqSetupS::isServer == true) the default-factory (e.g. MqFactoryDefault) will be used.

The executable is defined by (static) void MqInitSetArg0(MK_BAC bfl) and will be automatical set for a non C / C++ language.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]ctxthe MqContextS instance to work on
[in]argscommand-line-arguments to configure the client-server-link
Returns
The MkErrorE status from the DEFAULT MkErrorC in MkRuntimeS::error_mk

◆ MqLinkCreateChild_RT()

MQ_EXTERN enum MkErrorE MqLinkCreateChild_RT ( MK_RT const mkrt,
MQ_CTX const ctx,
MQ_CTX const parent,
MK_BAC const args )

make a context to a child-context on-top of an existing parent-client-server-link

A child is using the same process or thread as the parent but a different namespace. With a different namespace a child is able to act on different services on the shared server.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]ctxthe MqContextS instance to work on
[in]parentthe parent-context defined with MqLinkCreate
[in]argscommand-line-arguments to configure the client-server-link without the "@" item.
Returns
The MkErrorE status from the DEFAULT MkErrorC in MkRuntimeS::error_mk

◆ MqLinkDefault_RT()

MQ_EXTERN enum MkErrorE MqLinkDefault_RT ( MK_RT const mkrt,
MQ_CTX const ctx,
MK_BAC const args )

callback as wrapper for MqLinkCreate or MqLinkCreateChild with additional error-check code …

The function have to be used as argument to MqCtxTypeS::Child or MqCtxTypeS::Parent as default context-create function. Return an error if an unknown command-line-argument was found.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]ctxthe MqContextS instance to work on
[in]argscommand-line-arguments to configure the client-server-link with or without the "@" item.
Returns
The MkErrorE status from the DEFAULT MkErrorC in MkRuntimeS::error_mk

◆ MqLinkDelete_RT()

MQ_EXTERN void MqLinkDelete_RT ( MK_RT const mkrt,
MQ_CTX const ctx )

close the client-server-link

On a client the context will be set to not-connected and the function MqLinkIsConnected will return MK_NO. On a server the context will be deleted but only if MqSetupS::ignoreExit is not set to MK_YES. If the link is already not-connected nothing will happen.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]ctxthe MqContextS instance to work on

◆ MqLinkGetCtxId()

MK_NUM MqLinkGetCtxId ( MQ_CTX const ctx)
inline

get an identifier which is unique per parent-or-child-context

The context-identifier is a number and is used in the protocol to link a data-package to a context-pointer. This is necessary because the communication interface is shared between the parent-context and the child-context. This number is unique.

Parameters
[in]ctxthe MqContextS instance to work on
Returns
the identifier as number

Definition at line 5263 of file LibMqMsgque_mq.h.

5263 {
5264 return ctx ? ctx->link.ctxId : 0;
5265};

◆ MqLinkGetCtxIdP()

MQ_EXTERN MK_NUM MqLinkGetCtxIdP ( MQ_CTX const ctx)

Non-inline replacement for MqLinkGetCtxId

◆ MqLinkGetParent()

MQ_CTX MqLinkGetParent ( MQ_CTX const ctx)
inline

get the initial parent-context from a client/server link …

Parameters
[in]ctxthe MqContextS instance to work on
Returns
the parent-context or MK_NULL if ctx is MK_NULL

Definition at line 5234 of file LibMqMsgque_mq.h.

5234 {
5235 // BUF FIX: result always a context id "ctx" is valid
5236 // test: Nhi1Exec lcconfig.test --block-2 --fast-testing --lang-tcl -verbose e
5237 // -match lcconfig-2-5-* --num "1 3 1" --com-uds
5238 // RPC send "object-delete-message" on server-parent-context which can be
5239 // a client-child. The MqLinkGetParent is used to resolve this
5240 // file: LibLcConfigRpcClient.tcl
5241 return ctx ? MQ_GET_PARENT(ctx) : NULL;
5242};
#define MQ_GET_PARENT(ctx)

◆ MqLinkGetParentP()

MQ_EXTERN MQ_CTX MqLinkGetParentP ( MQ_CTX const ctx)

Non-inline replacement for MqLinkGetParent

◆ MqLinkGetTargetIdent()

MK_STRN MqLinkGetTargetIdent ( MQ_CTX const ctx)
inline

get the ident of the link-target

This function is only useful if the link is up and running.

Parameters
[in]ctxthe MqContextS instance to work on
Returns
get the ident of the link-target or MK_NULL if not connected

Definition at line 5274 of file LibMqMsgque_mq.h.

5274 {
5275 return ctx && ctx->link.ctxIdP ? ctx->link.ctxIdP->link.targetIdent : "";
5276};

◆ MqLinkGetTargetIdentP()

MQ_EXTERN MK_STRN MqLinkGetTargetIdentP ( MQ_CTX const ctx)

Non-inline replacement for MqLinkGetTargetIdent

◆ MqLinkIsConnected()

MQ_EXTERN bool MqLinkIsConnected ( MQ_CTX const ctx)

is the context connected? …

A context is connected if the MqLinkCreate command was successful. A context is not connected if:

  • the context has just been created and not connected
  • the link was deleted with MqLinkDelete
Parameters
[in]ctxthe MqContextS instance to work on
Returns
a boolean value, MK_YES or MK_NO

◆ MqLinkIsParent()

bool MqLinkIsParent ( MQ_CTX const ctx)
inline

is the context a parent-context? …

A context is a parent-context if it was created with MqLinkCreate

Parameters
[in]ctxthe MqContextS instance to work on
Returns
a boolean value, MK_YES or MK_NO

Definition at line 5250 of file LibMqMsgque_mq.h.

5250 {
5251 return ctx ? MQ_IS_PARENT(ctx) : false;
5252};
#define MQ_IS_PARENT(ctx)

◆ MqLinkIsParentP()

MQ_EXTERN MK_BOOL MqLinkIsParentP ( MQ_CTX const ctx)

Non-inline replacement for MqLinkIsParent

◆ MqLinkShutdown_RT()

MQ_EXTERN enum MkErrorE MqLinkShutdown_RT ( MK_RT const mkrt,
MQ_CTX const ctx )

shutdown the communication with a server

The following tasks are performend:

  • shutdown all childs
  • shutdown all slaves
  • client send the shutdown-sequence to the server
  • server answer the shutdown-sequence from the client
  • if parantshutdown the communication infrastructure
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]ctxthe MqContextS instance to work on
Returns
The MkErrorE status from the DEFAULT MkErrorC in MkRuntimeS::error_mk