Command Processing

Command Processing — Handling of commands received from consumers

Synopsis


#include <monitor/producer/commands.h>


            prod_cmd;
            prod_cmd_collect_args;
            prod_cmd_def_ch_args;
            prod_cmd_get_args;
            prod_cmd_auth_args;
            prod_cmd_ctx;
prod_cmd*   prod_cmd_new                    (mon_cmd cmd_code,
                                             uint32_t cmd_seq);
void        prod_cmd_free                   (prod_cmd *cmd);
int         prod_cmd_dispatch               (prod_cmd *cmd,
                                             prod_conn *conn);

Description

Details

prod_cmd

typedef struct {
	mon_cmd			cmd;
	uint32_t		cmd_seq;

	void			(*free_args)(prod_cmd *cmd);

	union
	{
		prod_cmd_collect_args	collect;
		prod_cmd_get_args	stop;
		prod_cmd_get_args	subscribe;
		prod_cmd_get_args	buffer;
		prod_cmd_get_args	get;
		prod_cmd_auth_args	auth;
		prod_cmd_def_ch_args	def_ch;
		uint32_t		set_ch;
		uint32_t		del_ch;
		uint64_t		commit;
		prod_cmd_collect_args	execute;
		prod_cmd_collect_args	query;
		char			*wrap;

		/* Placeholder marking the size of the union */
		uint32_t		dummy[3];
	} args;
} prod_cmd;

Represents a command received by the producer.

mon_cmd cmd;the command code (see mon_cmd).
uint32_t cmd_seq;the command's sequence number.
free_args ()method to free the command's arguments.

prod_cmd_collect_args

typedef struct {
	char			*name;
	mon_arg_list		*arglist;
} prod_cmd_collect_args;

Arguments for COLLECT, QUERY and EXECUTE.

char *name;the name of the metric/control.
mon_arg_list *arglist;the arguments for the metric/control.

prod_cmd_def_ch_args

typedef struct {
	char			*url;
	mon_arg_list		*arglist;
} prod_cmd_def_ch_args;

Arguments for DEF_CHANNEL.

char *url;the URL of the channel.
mon_arg_list *arglist;the arguments of the channel.

prod_cmd_get_args

typedef struct {
	uint32_t		metric_id;
	uint32_t		conn_id;
} prod_cmd_get_args;

Arguments for GET, STOP, SUBSCRIBE and BUFFER.

uint32_t metric_id;a metric id.
uint32_t conn_id;the target channel id.

prod_cmd_auth_args

typedef struct {
	char			*method;
	void			*credentials;
	uint32_t		credlen;
} prod_cmd_auth_args;

Arguments for AUTH.

char *method;the authentication method.
void *credentials;opaque credentials.
uint32_t credlen;the length of the credentials.

prod_cmd_ctx

typedef struct {
	prod_conn		*conn;
	prod_cmd		*cmd;
	mon_ctx			*ctx;
} prod_cmd_ctx;

Command context used for asynchronous execution.

prod_conn *conn;the prod_conn this command arrived on.
prod_cmd *cmd;the prod_cmd.
mon_ctx *ctx;the mon_ctx this context belongs to.

prod_cmd_new ()

prod_cmd*   prod_cmd_new                    (mon_cmd cmd_code,
                                             uint32_t cmd_seq);

Allocates a new prod_cmd.

cmd_code :the command code (see mon_cmd).
cmd_seq :the command's sequence number.
Returns :a new prod_cmd or NULL if out of memory.

prod_cmd_free ()

void        prod_cmd_free                   (prod_cmd *cmd);

Deallocate a prod_cmd.

cmd :a prod_cmd.

prod_cmd_dispatch ()

int         prod_cmd_dispatch               (prod_cmd *cmd,
                                             prod_conn *conn);

Execute a prod_cmd.

cmd :a prod_cmd.
conn :the prod_conn where the command was received.
Returns :0 if successful or an error code.