Agent

Agent

The class used to model the axios http instance and agent

Constructor

new Agent()

Source:

Members

agent :String

The client's custom http or https agent.

Source:
Type:
  • String

connection :Class

maximum amount of concurrent requests to send.

Source:
Type:
  • Class

delay :String

A delay between checking for request responses.

Source:
Type:
  • String

global :String

The global id for an http or https.agent

Source:
Type:
  • String

pending :Array

requests awaiting responses.

Source:
Type:
  • Array

protocol :String

The protocol for the client.

Source:
Type:
  • String

proxy :Object

A proxy to use for requests.

Source:
Type:
  • Object

queue :Array

requests queued for sending.

Source:
Type:
  • Array

timeout :String

A timeout for requests.

Source:
Type:
  • String

Methods

(private, static) globalize(protocol, agent) → {Object}

globalize will create the global agent scope if it does not exist. It will set a global Id for retrieval later and create a new http or https module depending on the protocol passed to it.

Source:
Parameters:
Name Type Description
protocol String

The protocol to use when creating an Agent.

agent Object

The name of the script

Returns:
Type:
Object

returns a globalized request agent

(static) handleError(error) → {Promise}

This function evaluates the error response. This function will substitute a non JSON error or a bad gateway status with a JSON code and message error. This function will add an expired property to the error response if it recieves a invalid token response.

Source:
Parameters:
Name Type Description
error Object

The error recieved from the requested resource.

Returns:
Type:
Promise

A promise rejection containing a code and a message

(private, static) handleRequest(config) → {Promise}

handles request data before it is sent to the resource. This function will eventually be used to cancel the request and return the configuration body. This function will test the url for an http proticol and reject if none exist.

Source:
Parameters:
Name Type Description
config Object

The axios request configuration

Returns:
Type:
Promise

the request configuration object

(private, static) handleResponse(response) → {Promise}

handles request data before it is sent to the resource. This function will eventually be used to cancel the request and return the configuration body. This function will test the url for an http proticol and reject if none exist.

Source:
Parameters:
Name Type Description
response Object

The axios response

Returns:
Type:
Promise

the request configuration object

(private, static) localize() → {Object}

localize will check to see if a global agent exists. If the agent does not exist this method will call _globalize to add it.

Source:
See:
  • globalize
Returns:
Type:
Object

returns a globalized request agent

(private, static) mutate(request, mutation) → {Object}

This method is used to modify keys in an object. This method is used by the watch and resolve methods to allow request data to be written to the datastore.

Source:
See:
  • Agent#resolve
  • Agent#watch
  • Utilities#deepMapKeys
Parameters:
Name Type Description
request Object

The agent request object.

mutation function

The function to upon each key in the request.

Returns:
Type:
Object

This mutated request

(private, static) push(agent)

the push method queues requests and begins the request watcher process. This method will also call shift to ensure a request is being processed.

Source:
See:
  • Agent#watch
  • Agent#mutate
  • Agent#shift
Parameters:
Name Type Description
agent Object

The agent request configuration.

Name Type Description
request Object

The agent request object.

resolve function

The function to call when the request has been completed.

(static) request(data, parametersopt) → {Object}

request will merge agent properties with request properties in order to make the request. This method removes httpAgent and httpsAgents through destructoring.

Source:
See:
  • localize
  • push
  • handleResponse
  • handleRequest
  • handleError
Parameters:
Name Type Attributes Description
data Object

The request

parameters Object <optional>

The request parameters. Individualized request parameters.

Returns:
Type:
Object

request The configured axios instance to use for a request.

(private, static) resolve()

This method resolves requests by sending them to FileMaker for processing. This method will resolve requests currently in the pending queue. This method will inject the available session token into the request.

Source:
See:

(private, static) shift()

the shift method will send a request if there are less pending requests than the set limit.

Source:
See:
  • agent#concurrency

(private, static) watch(reject)

This method creates a timer to check on the status of queued and resolved requests This method will queue and resolve requests based on the number of incoming requests and the availability of sessions. This method will resolve requests and create sessions based upon the agent's configured concurrency. token response.

Source:
See:
  • Agent#concurrency
  • Connection@available
Parameters:
Name Type Description
reject function

The reject function from the promise that initiated the function.

preDelete(data)

The agent preDelete hook will remove an Agent from the global scope when the client is destroyed.

Source:
Parameters:
Name Type Description
data Object

The data used to create the client.

preInit(data)

The agent preInit hook creates a global agent for the client to use if one is required.

Source:
See:
  • _globalize
Parameters:
Name Type Description
data Object

The data used to create the agent.

Agent

new Agent()

Source:

Members

agent :String

The client's custom http or https agent.

Source:
Type:
  • String

connection :Class

maximum amount of concurrent requests to send.

Source:
Type:
  • Class

delay :String

A delay between checking for request responses.

Source:
Type:
  • String

global :String

The global id for an http or https.agent

Source:
Type:
  • String

pending :Array

requests awaiting responses.

Source:
Type:
  • Array

protocol :String

The protocol for the client.

Source:
Type:
  • String

proxy :Object

A proxy to use for requests.

Source:
Type:
  • Object

queue :Array

requests queued for sending.

Source:
Type:
  • Array

timeout :String

A timeout for requests.

Source:
Type:
  • String

Methods

(private, static) globalize(protocol, agent) → {Object}

globalize will create the global agent scope if it does not exist. It will set a global Id for retrieval later and create a new http or https module depending on the protocol passed to it.

Source:
Parameters:
Name Type Description
protocol String

The protocol to use when creating an Agent.

agent Object

The name of the script

Returns:
Type:
Object

returns a globalized request agent

(static) handleError(error) → {Promise}

This function evaluates the error response. This function will substitute a non JSON error or a bad gateway status with a JSON code and message error. This function will add an expired property to the error response if it recieves a invalid token response.

Source:
Parameters:
Name Type Description
error Object

The error recieved from the requested resource.

Returns:
Type:
Promise

A promise rejection containing a code and a message

(private, static) handleRequest(config) → {Promise}

handles request data before it is sent to the resource. This function will eventually be used to cancel the request and return the configuration body. This function will test the url for an http proticol and reject if none exist.

Source:
Parameters:
Name Type Description
config Object

The axios request configuration

Returns:
Type:
Promise

the request configuration object

(private, static) handleResponse(response) → {Promise}

handles request data before it is sent to the resource. This function will eventually be used to cancel the request and return the configuration body. This function will test the url for an http proticol and reject if none exist.

Source:
Parameters:
Name Type Description
response Object

The axios response

Returns:
Type:
Promise

the request configuration object

(private, static) localize() → {Object}

localize will check to see if a global agent exists. If the agent does not exist this method will call _globalize to add it.

Source:
See:
  • globalize
Returns:
Type:
Object

returns a globalized request agent

(private, static) mutate(request, mutation) → {Object}

This method is used to modify keys in an object. This method is used by the watch and resolve methods to allow request data to be written to the datastore.

Source:
See:
  • Agent#resolve
  • Agent#watch
  • Utilities#deepMapKeys
Parameters:
Name Type Description
request Object

The agent request object.

mutation function

The function to upon each key in the request.

Returns:
Type:
Object

This mutated request

(private, static) push(agent)

the push method queues requests and begins the request watcher process. This method will also call shift to ensure a request is being processed.

Source:
See:
  • Agent#watch
  • Agent#mutate
  • Agent#shift
Parameters:
Name Type Description
agent Object

The agent request configuration.

Name Type Description
request Object

The agent request object.

resolve function

The function to call when the request has been completed.

(static) request(data, parametersopt) → {Object}

request will merge agent properties with request properties in order to make the request. This method removes httpAgent and httpsAgents through destructoring.

Source:
See:
  • localize
  • push
  • handleResponse
  • handleRequest
  • handleError
Parameters:
Name Type Attributes Description
data Object

The request

parameters Object <optional>

The request parameters. Individualized request parameters.

Returns:
Type:
Object

request The configured axios instance to use for a request.

(private, static) resolve()

This method resolves requests by sending them to FileMaker for processing. This method will resolve requests currently in the pending queue. This method will inject the available session token into the request.

Source:
See:

(private, static) shift()

the shift method will send a request if there are less pending requests than the set limit.

Source:
See:
  • agent#concurrency

(private, static) watch(reject)

This method creates a timer to check on the status of queued and resolved requests This method will queue and resolve requests based on the number of incoming requests and the availability of sessions. This method will resolve requests and create sessions based upon the agent's configured concurrency. token response.

Source:
See:
  • Agent#concurrency
  • Connection@available
Parameters:
Name Type Description
reject function

The reject function from the promise that initiated the function.

preDelete(data)

The agent preDelete hook will remove an Agent from the global scope when the client is destroyed.

Source:
Parameters:
Name Type Description
data Object

The data used to create the client.

preInit(data)

The agent preInit hook creates a global agent for the client to use if one is required.

Source:
See:
  • _globalize
Parameters:
Name Type Description
data Object

The data used to create the agent.