ExternalServer Struct Reference

A datatype to allow access to an external Grassroots Server. More...

#include <servers_manager.h>

Collaboration diagram for ExternalServer:
[legend]

Public Member Functions

ExternalServerAllocateExternalServer (const char *name_s, const char *uri_s, const char *uuid_s, ConnectionType ct)
 Allocate an ExternalServer. More...
 
void FreeExternalServer (ExternalServer *server_p)
 Free an ExternalServer. More...
 
json_t * MakeRemoteJSONCallToExternalServer (ExternalServer *server_p, json_t *request_p)
 Call a remote server. More...
 
bool AddExternalServerFromJSON (ServersManager *manager_p, const json_t *json_p)
 Add an ExternalServer from a JSON-based definition. More...
 
ExternalServerCreateExternalServerFromJSON (const json_t *json_p)
 Create a ExternalServer from a json_t object. More...
 
unsigned char * SerialiseExternalServerToJSON (ExternalServer *const external_server_p, unsigned int *value_length_p)
 Get a raw unsigned char array that allows the ExternalServer to be stored in the ServersManager. More...
 
ExternalServerDeserialiseExternalServerFromJSON (const unsigned char *raw_json_data_s)
 Create an ExternalServer from a raw data memory block. More...
 
json_t * GetExternalServerAsJSON (ExternalServer *server_p)
 Get the JSON fragment that describes the given ExternalServer. More...
 

Data Fields

char * es_name_s
 The user-friendly name of the server. More...
 
char * es_uri_s
 The URI for the Server. More...
 
Connectiones_connection_p
 The Connection to the ExternalServer. More...
 
uuid_t es_id
 A unique id to identify the ExternalServer. More...
 
LinkedListes_paired_services_p
 A List of KeyValuePairNodes where the key is the name of the Service on the local Server and the value is the name of the Service on this ExternalServer. More...
 

Detailed Description

A datatype to allow access to an external Grassroots Server.

This stores the information needed to consolidate the Services available on other Grassroots Servers

Member Function Documentation

◆ AllocateExternalServer()

ExternalServer * AllocateExternalServer ( const char *  name_s,
const char *  uri_s,
const char *  uuid_s,
ConnectionType  ct 
)

Allocate an ExternalServer.

Parameters
name_sThe user-friendly name for the server
uri_sThe URI to call for the ExternalServer's Services.
uuid_sThe string representation of the UUID to addign to the ExternalServer.
ctThe ConnectionType of how to connect to the ExternalServer
Returns
A newly-allocated ExternalServer or NULL upon error.
See also
FreeExternalServer

◆ FreeExternalServer()

void FreeExternalServer ( ExternalServer server_p)

Free an ExternalServer.

Parameters
server_pThe ExternalServer to free.

◆ MakeRemoteJSONCallToExternalServer()

json_t * MakeRemoteJSONCallToExternalServer ( ExternalServer server_p,
json_t *  request_p 
)

Call a remote server.

This will proxy a call to an ExternalServer and will return the response to the user. All of this happens transparently from the user's point of view, the requested service appears to be running on this Server.

Parameters
server_pThe ExternalServer to proxy the request to.
request_pThe request to proxy.
Returns
The response from the given ExternalServer.

◆ AddExternalServerFromJSON()

bool AddExternalServerFromJSON ( ServersManager manager_p,
const json_t *  json_p 
)

Add an ExternalServer from a JSON-based definition.

This will read in the SERVERS_S json object within the global configuration file and build the ExternalServer definitions from it.

Parameters
json_pThe global configuration json_t object.
Returns
bool true if the ExternalServer was generated successfully, false otherwise.
See also
SERVERS_S
ServersManager

◆ CreateExternalServerFromJSON()

ExternalServer * CreateExternalServerFromJSON ( const json_t *  json_p)

Create a ExternalServer from a json_t object.

This will create a ExternalServer from a json_t object.

Parameters
json_pThe json object representing a ExternalServer.
Returns
true if the v was created successfully, false otherwise.

◆ SerialiseExternalServerToJSON()

unsigned char * SerialiseExternalServerToJSON ( ExternalServer *const  external_server_p,
unsigned int *  value_length_p 
)

Get a raw unsigned char array that allows the ExternalServer to be stored in the ServersManager.

The array is the result of GetExternalServerAsJSON converted to a string

Parameters
external_server_pThe ExternalServer to serialise.
value_length_pUpon success, the length in bytes of the resultant array will be stored here.
Returns
The serialised representation of the ExternalServer or NULL upon error.
See also
DeserialiseExternalServerToJSON

◆ DeserialiseExternalServerFromJSON()

ExternalServer * DeserialiseExternalServerFromJSON ( const unsigned char *  raw_json_data_s)

Create an ExternalServer from a raw data memory block.

Parameters
raw_json_data_sThe raw data from a previous call to SerialiseExternalServerToJSON.
Returns
The newly-created ExternalServer or NULL upon error.
See also
SerialiseExternalServerToJSON

◆ GetExternalServerAsJSON()

json_t * GetExternalServerAsJSON ( ExternalServer server_p)

Get the JSON fragment that describes the given ExternalServer.

Parameters
server_pThe ExternalServer to get the JSON fragment for.
Returns
The JSON fragment or NULL upon error.

Field Documentation

◆ es_name_s

char* es_name_s

The user-friendly name of the server.

◆ es_uri_s

char* es_uri_s

The URI for the Server.

◆ es_connection_p

Connection* es_connection_p

◆ es_id

uuid_t es_id

A unique id to identify the ExternalServer.

This is only unique for this Server. It is for tracking requests for given Services.

◆ es_paired_services_p

LinkedList* es_paired_services_p

A List of KeyValuePairNodes where the key is the name of the Service on the local Server and the value is the name of the Service on this ExternalServer.


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