wille.services

Wille Services Module

Mostly used internally by Wille. However, a developer using Wille may need to understand how Wille Service Definitions work.

Examples:

>>> import services 
Currently two types of services are supported:
  • Local services: executed locally, as specified in service adapter (see readme.txt)
  • HTTP services: executed over an HTTP API

Let’s first see how local services work.

Initiating an instance of a local service: >>> service = services.LocalService(‘../tests’, ‘upload_test’, ‘examples/libs’)

Some metadata for services are available, such as parameter list: >>> service.required_params [‘raw_data’, ‘checksum’]

Once instantiated, services can be executed with specified parameters: >>> result = service.execute({‘raw_data’:’<h1>Hello World!</h1>’, ‘checksum’: ‘1682’})

Result is return in ServiceData format. As an example, let’s count length of returned data: print(result.data)

class wille.services.GlobalServicePool

A collection of service pools

execute_service(name=None, type=None, uri=None, params=None, keyring=None, profile=None, prefer_index=0)

Run a service matching specified criteria Parameters:

name - Service name (default=ANY) type - Service type (default=ANY) uri - Service uri (default=ANY) params - Service parameters as required by it (default=None) keyring - Keyring (default=None) prefer_index - In case several service match request, prefer this (nth) service (default=0)
execute_services(service_descriptions, keyring=None)
Executes a group of services. Parameters:
service_descriptions - List of services to be executed. Each service is dict() with keys:
name - Name of service to execute (None/ANY=not specified) type - Service type (None/ANY=not specified) uri - Service URI profile - Service profile params - Service parameters

keyring - Keyring (optional)

Note: minimum execution type 10 ms due use of polling

Returns:
List of service results on matching order
pools(pooltype=None)

List pools

services(name=None, type=None, uri=None, pooltype=None, profile=None)

Find services by specified criteria:

class wille.services.HTTPService(url, name='', type=None, description='', all_params=None, required_params=None)

HTTP Service

execute(params, servicepool=None, keyring=None)

Executes an HTTP service. Will manage Zipblob results automatically.

reload()

Reload service

class wille.services.HTTPServicePool(server_url=None)

Pool for HTTP Services

connect_to(server_url)

Connect/update connection to a server

services(name=None, type=None, uri=None, profile=None)

Find services Arguments:

type – Match by type (Default=ANY)
class wille.services.LocalService(parent_dir, subdir, libs_dir)

Local service

reload()

Reload service

status_ok()

Is service status ok?

class wille.services.LocalServicePool(services_dir, libs_dir)

Pool for local services

class wille.services.Service

Base class for all Wille services

class wille.services.ServiceData(data, metadata)

ServiceData - either input or output

success()

Returns True/False based on whether this instance contains a successful service result.

If undetermined (such as for service input data), returns None

class wille.services.ServicePool

Pool for services

services(name=None, type=None, uri=None, profile=None)

Returns services in pool matching specified criteria. At least one parameter must be specified

Parameters:
name - Match service any (Default=ANY) type - Service type (Default=ANY) uri - Service URI (Default=ANY)

Previous topic

wille.server

Next topic

wille.commandline

This Page