Skip to content
tr4n2uil edited this page Dec 9, 2012 · 15 revisions

A service is defined by any class that implements the iservice interface.

iService interface

The iservice interface defines three methods to be implemented by the concrete services: input(), run() and output().

input method

returns: {
    'required': [],   // array of arguments which are required to be passed into the service
    'optional': {},   // map of keys which are optional arguments to be passed into the service 
                         with the default value as the value of the key in the map
    'set': []         // array of values to be set by positional arguments
}

run method

implements the service which processes an invoking message and returns results in same message

params: memory = {}   // iobject representing the message invoking the service
                         in case of python, specified arguments obtained as keyword arguments and 
                         memory used for unspecified arguments only

output method

return: []           // array of keys whose values are to be used as output in a workflow

Example

The following is an example service in python:

class Greet( snowblozm.iService ):
	def input( self ):
		return { 
			'optional': { 
				'name': 'Krishna' 
			}, 
			'set': [ 'name' ] 
		}

	def run( self, name, **memory ):
		print 'Hello World', name, '!'
		return snowblozm.utils( memory )
		
	def output( self ):
		return []

snowblozm core interfaces

Learn more about our other core interfaces:

Clone this wiki locally