Users

Users — Managing connected users

Synopsis


#include <monitor/producer/user.h>


            prod_user;
            prod_user_stats;
prod_user*  prod_user_get                   (const char *username);
void        prod_user_done                  (prod_user *user);
void        prod_user_ref                   (prod_user *user);
uint32_t    prod_user_mid_next              (prod_user *user);
int         prod_user_mid_add               (prod_user *user,
                                             prod_metric_id *mid);
void        prod_user_mid_del               (prod_user *user,
                                             prod_metric_id *mid);
prod_metric_id* prod_user_mid_get           (prod_user *user,
                                             uint32_t id);
int         prod_user_conn_add              (prod_user *user,
                                             prod_conn *conn);
void        prod_user_conn_del              (prod_user *user,
                                             prod_conn *conn);
prod_conn*  prod_user_conn_get              (prod_user *user,
                                             uint32_t id);

Description

Details

prod_user

typedef struct {
	char			*name;
	GList			*connections;
	uint32_t		mid_gen;
	GHashTable		*mids;
	prod_metric_id		*mid_list;

	prod_user_stats		stats;
	prod_user_stats		limits;

	int			refcnt;
} prod_user;

Structure storing information about an user inside the producer.

char *name;the user's name.
GList *connections;list of connections belonging to this user.
uint32_t mid_gen;the metric id generator, used by prod_user_mid_get().
GHashTable *mids;hash table for the prod_metric_id structures belonging to this user.
prod_metric_id *mid_list;list of the prod_metric_id structures belonging to this user.
prod_user_stats stats;resource usage statistics.
prod_user_stats limits;resource limits.
int refcnt;reference count.

prod_user_stats

typedef struct {
	unsigned int		connections;
	unsigned int		mids;
} prod_user_stats;

Per-user resource usage statistics.

unsigned int connections;number of live connections.
unsigned int mids;number of metric IDs in use.

prod_user_get ()

prod_user*  prod_user_get                   (const char *username);

Retrieves the prod_user structure belonging to username. If such structure already existed, its reference count is incremented; otherwise a new structure is allocated.

username :the user's name.
Returns :a prod_user or NULL if there were not enough memory.

prod_user_done ()

void        prod_user_done                  (prod_user *user);

Decrements the reference count of a prod_user. If the reference count reaches 0, the prod_user structure is deallocated.

user :a prod_user.

prod_user_ref ()

void        prod_user_ref                   (prod_user *user);

Increments the reference count of a prod_user.

user :a prod_user.

prod_user_mid_next ()

uint32_t    prod_user_mid_next              (prod_user *user);

Returns the next unused metric id for the user.

user :a prod_user.
Returns :the next unused metric id.

prod_user_mid_add ()

int         prod_user_mid_add               (prod_user *user,
                                             prod_metric_id *mid);

Adds a new prod_metric_id to a prod_user. Also updates the statistics.

user :a prod_user.
mid :a prod_metric_id.
Returns :0 if successful or MON_ERR_RES_LIMIT if resource limits are exceeded.

prod_user_mid_del ()

void        prod_user_mid_del               (prod_user *user,
                                             prod_metric_id *mid);

Removes a prod_metric_id from a prod_user. Also updates the statistics.

user :a prod_user.
mid :a prod_metric_id.

prod_user_mid_get ()

prod_metric_id* prod_user_mid_get           (prod_user *user,
                                             uint32_t id);

Returns a prod_metric_id structure belonging to user based on its numeric id.

user :a prod_user.
id :the numeric metric id.
Returns :a prod_metric_id or NULL if id is invalid.

prod_user_conn_add ()

int         prod_user_conn_add              (prod_user *user,
                                             prod_conn *conn);

Adds a new prod_conn to a prod_user. Also updates the statistics.

user :a prod_user.
conn :a prod_conn.
Returns :0 if successful or MON_ERR_RES_LIMIT if resource limits are exceeded.

prod_user_conn_del ()

void        prod_user_conn_del              (prod_user *user,
                                             prod_conn *conn);

Removes a prod_conn from a prod_user. Also updates the statistics.

user :a prod_user.
conn :a prod_conn.

prod_user_conn_get ()

prod_conn*  prod_user_conn_get              (prod_user *user,
                                             uint32_t id);

Returns a prod_conn structure belonging to user based on its numeric id.

user :a prod_user.
id :a numeric channel id.
Returns :a prod_conn or NULL if id is invalid.