ProvidersStateTable Struct Reference

This is a datatype that is used to keep track of which servers and services have already been processed when merging services together to present to a server or client. More...

#include <providers_state_table.h>

Public Member Functions

ProvidersStateTableAllocateProvidersStateTable (const json_t *req_p)
 Allocate a ProvidersStateTable and populate it with any details within a specified json request. More...
 
void FreeProvidersStateTable (ProvidersStateTable *providers_p)
 Deallocate a ProvidersStateTable. More...
 
ProvidersStateTableGetInitialisedProvidersStateTable (const json_t *req_p, LinkedList *services_p, GrassrootsServer *grassroots_p)
 Create a new ProvidersStateTable and populate it with any details within a specified json request and a list of Services for this Server. More...
 
ProvidersStateTableGetInitialisedProvidersStateTableForSingleService (const json_t *req_p, const char *const server_uri_s, const char *const service_s)
 Create a new ProvidersStateTable and populate it with any details within a specified json request and a single Server-Service pair. More...
 
bool AddToProvidersStateTable (ProvidersStateTable *providers_p, const char *server_uri_s, const char *service_s)
 Add a server and service to a ProvidersStateTable. More...
 
bool IsServiceInProvidersStateTable (const ProvidersStateTable *providers_p, const char *server_uri_s, const char *service_s)
 Check whether a given server and service are in a ProvidersStateTable. More...
 
json_t * GetProvidersStateTableAsJSON (const ProvidersStateTable *providers_p)
 Get the json representation of a ProvidersStateTable. More...
 
json_t * GetAvailableServicesRequestForAllProviders (const ProvidersStateTable *providers_p, UserDetails *user_p, const SchemaVersion *const sv_p)
 Create a json request that to get the list of all available Services making sure not to duplicate any Server-Service pairs stored within a given ProvidersStateTable. More...
 
bool AddServicesListToProvidersStateTable (ProvidersStateTable *providers_p, LinkedList *services_p, GrassrootsServer *grassroots_p)
 Add a list of Services for this Server to a ProvidersStateTable. More...
 
bool AddProvidersStateTableToRequest (const ProvidersStateTable *providers_p, json_t *req_p)
 Add the details to a json request to get the list of all available Services on a Server making sure not to duplicate any Server-Service pairs stored within a given ProvidersStateTable. More...
 
bool InitProvidersStateTableFromRequest (ProvidersStateTable *const providers_p, const json_t *const req_p)
 Add the details from a json request to a given ProvidersStateTable. More...
 
bool ClearProvidersStateTable (ProvidersStateTable *providers_p)
 Clear all of the servers and services that are being tracked within a ProvidersStateTable. More...
 
bool ReinitProvidersStateTable (ProvidersStateTable *providers_p, const json_t *const req_p, const char *server_uri_s, const char *service_name_s)
 Clear a given ProvidersStateTable and add the details from a json request and a given Server-Service pair to it. More...
 

Detailed Description

This is a datatype that is used to keep track of which servers and services have already been processed when merging services together to present to a server or client.

As requests are sent between connected Servers, a ProvidersStateTable maintains a list of the Services already used on each Server. This is used to, for instance, prevent deadlocks occurring where two Servers have connected Services with each other.

Examples
long_running_service.c.

Member Function Documentation

◆ AllocateProvidersStateTable()

ProvidersStateTable * AllocateProvidersStateTable ( const json_t *  req_p)

Allocate a ProvidersStateTable and populate it with any details within a specified json request.

Parameters
req_pThe json_t request to populate the ProvidersStateTable with. Any previous ProvidersStateTable details will be stored by placing the output of GetProvidersStateTableAsJSON with the SERVERS_S key.
Returns
The newly-allocated ProvidersStateTable or NULL upon error.
See also
SERVERS_S
GetProvidersStateTableAsJSON
InitProvidersStateTableFromRequest

◆ FreeProvidersStateTable()

void FreeProvidersStateTable ( ProvidersStateTable providers_p)

Deallocate a ProvidersStateTable.

Parameters
providers_pThe ProvidersStateTable to free.

◆ GetInitialisedProvidersStateTable()

ProvidersStateTable * GetInitialisedProvidersStateTable ( const json_t *  req_p,
LinkedList services_p,
GrassrootsServer grassroots_p 
)

Create a new ProvidersStateTable and populate it with any details within a specified json request and a list of Services for this Server.

Parameters
req_pThe json_t request to populate the ProvidersStateTable with. Any previous ProvidersStateTable details will be stored by placing the output of GetProvidersStateTableAsJSON with the SERVERS_S key.
services_pA LinkedList of ServiceNodes that will get added to the ProvidersStateTable for this Server.
Returns
The newly-allocated ProvidersStateTable or NULL upon error.
See also
AllocateProvidersStateTable
AddServicesListToProvidersStateTable

◆ GetInitialisedProvidersStateTableForSingleService()

ProvidersStateTable * GetInitialisedProvidersStateTableForSingleService ( const json_t *  req_p,
const char *const  server_uri_s,
const char *const  service_s 
)

Create a new ProvidersStateTable and populate it with any details within a specified json request and a single Server-Service pair.

Parameters
req_pThe json_t request to populate the ProvidersStateTable with. Any previous ProvidersStateTable details will be stored by placing the output of GetProvidersStateTableAsJSON with the SERVERS_S key.
server_uri_sThe URI of the Server to add to the ProvidersStateTable if it is not already there.
service_sThe name of the Service for the given Server that will be added to the ProvidersStateTable.
Returns
The newly-allocated ProvidersStateTable or NULL upon error.
See also
AllocateProvidersStateTable
AddToProvidersStateTable

◆ AddToProvidersStateTable()

bool AddToProvidersStateTable ( ProvidersStateTable providers_p,
const char *  server_uri_s,
const char *  service_s 
)

Add a server and service to a ProvidersStateTable.

Parameters
providers_pThe ProvidersStateTable to amend.
server_uri_sThe unique identifier for a server. The URI for the server is used.
service_sThe name of the service to add.
Returns
true if the service was added to the ProvidersStateTable successfully, false otherwise.

◆ IsServiceInProvidersStateTable()

bool IsServiceInProvidersStateTable ( const ProvidersStateTable providers_p,
const char *  server_uri_s,
const char *  service_s 
)

Check whether a given server and service are in a ProvidersStateTable.

Parameters
providers_pThe ProvidersStateTable to check.
server_uri_sThe URI for the server.
service_sThe name of the service.
Returns
true if the server-service pair is in the given ProvidersStateTable, false otherwise.

◆ GetProvidersStateTableAsJSON()

json_t * GetProvidersStateTableAsJSON ( const ProvidersStateTable providers_p)

Get the json representation of a ProvidersStateTable.

Parameters
providers_pThe ProvidersStateTable to get the json representation of
Returns
The json representation or NULL upon error.

◆ GetAvailableServicesRequestForAllProviders()

json_t * GetAvailableServicesRequestForAllProviders ( const ProvidersStateTable providers_p,
UserDetails user_p,
const SchemaVersion *const  sv_p 
)

Create a json request that to get the list of all available Services making sure not to duplicate any Server-Service pairs stored within a given ProvidersStateTable.

Parameters
providers_pThe ProvidersStateTable detailing all of the Server-Service pairs already processed.
user_pAn optional UserDetails for the current User if access restrictions to any Server-Service combinations sent in response to the request generated by this method.
sv_pIf you wish to create a JSON fragment for a different version of the Grassroots system, then you can set this value to the version that you require. If this is NULL, then the current version of the running Grassroots system will be used.
Returns
The json representation or NULL upon error.
See also
AddProvidersStateTableToRequest

◆ AddServicesListToProvidersStateTable()

bool AddServicesListToProvidersStateTable ( ProvidersStateTable providers_p,
LinkedList services_p,
GrassrootsServer grassroots_p 
)

Add a list of Services for this Server to a ProvidersStateTable.

Parameters
providers_pThe ProvidersStateTable to add the Service definitions to.
services_pA LinkedList of ServiceNodes that will get added to the ProvidersStateTable for this Server.
Returns
true if the Services were added successfully or false upon error.

◆ AddProvidersStateTableToRequest()

bool AddProvidersStateTableToRequest ( const ProvidersStateTable providers_p,
json_t *  req_p 
)

Add the details to a json request to get the list of all available Services on a Server making sure not to duplicate any Server-Service pairs stored within a given ProvidersStateTable.

Parameters
providers_pThe ProvidersStateTable detailing all of the Server-Service pairs already processed.
req_pThe json request to add the details to.
Returns
true if the ProvidersStateTable details were added to the given request successfully, false otherwise.

◆ InitProvidersStateTableFromRequest()

bool InitProvidersStateTableFromRequest ( ProvidersStateTable *const  providers_p,
const json_t *const  req_p 
)

Add the details from a json request to a given ProvidersStateTable.

Parameters
providers_pThe ProvidersStateTable to initialise.
req_pThe json request to extract the Server-Service details from and add to the given ProvidersStateTable.
Returns
true if the ProvidersStateTable was initialised successfully, false otherwise.

◆ ClearProvidersStateTable()

bool ClearProvidersStateTable ( ProvidersStateTable providers_p)

Clear all of the servers and services that are being tracked within a ProvidersStateTable.

Parameters
providers_pThe ProvidersStateTable to clear.
Returns
true if the ProvidersStateTable was cleared successfully, false otherwise.

◆ ReinitProvidersStateTable()

bool ReinitProvidersStateTable ( ProvidersStateTable providers_p,
const json_t *const  req_p,
const char *  server_uri_s,
const char *  service_name_s 
)

Clear a given ProvidersStateTable and add the details from a json request and a given Server-Service pair to it.

Parameters
providers_pThe ProvidersStateTable to reinitialise.
req_pThe json request to extract the Server-Service details from and add to the given ProvidersStateTable.
server_uri_sThe unique identifier for a server. The URI for the server is used.
service_name_sThe name of the service to add.
Returns
true if the ProvidersStateTable was reinitialised successfully, false otherwise.
See also
ClearProvidersStateTable
InitProvidersStateTableFromRequest
AddToProvidersStateTable

The documentation for this struct was generated from the following file: