nautilus.services package¶
Submodules¶
nautilus.services.apiGateway module¶
-
class
nautilus.services.apiGateway.APIGateway(*args, **kwds)[source]¶ Bases:
nautilus.services.service.ServiceThis provides a single endpoint that other services and clients can use to query the cloud without worrying about the distributed nature of the system.
Example
# external imports import nautilus # local imports from .schema import schema class MyAPIGateway(nautilus.APIGateway): schema = schema
-
action_handler¶ alias of
APIActionHandler
-
api_request_handler_class¶ alias of
APIQueryHandler
-
auth_criteria¶ This attribute provides the mapping of services to their auth requirement
Returns: the mapping from services to their auth requirements. Return type: (dict)
-
get_models()[source]¶ Returns the models managed by this service.
Returns: the models managed by the service Return type: (list)
-
init_db()[source]¶ This function configures the database used for models to make the configuration parameters.
-
login_user(password, **kwds)[source]¶ This function handles the registration of the given user credentials in the database
-
model¶ alias of
UserPassword
-
mutation_resolver(mutation_name, args, fields)[source]¶ the default behavior for mutations is to look up the event, publish the correct event type with the args as the body, and return the fields contained in the result
-
name= 'api'¶
-
object_resolver(object_name, fields, obey_auth=False, current_user=None, **filters)[source]¶ This function resolves a given object in the remote backend services
-
register_user(password, **kwds)[source]¶ This function is used to provide a sessionToken for later requests.
Parameters: uid (str) – The
-
secret_key= None¶
-
nautilus.services.authService module¶
nautilus.services.connectionService module¶
-
class
nautilus.services.connectionService.ConnectionService(**kwargs)[source]¶ Bases:
nautilus.services.modelService.ModelServiceThis service manages a “one-way” connection between two services. The underlying schema and database are automatically generated to match the primary keys of the linked services.
This service will listen for actions indicating the deletion of a related model and remove any related fields to maintain consistency. And provides a way for the api gateway to deduce the relationship between services when summarizing the cloud.
Parameters: services (list of nautilus.Service) – The list of services to connect. Example
# external imports import nautilus class ServiceConfig: database_url = 'sqlite:////tmp/connections.db' class MyConnection(nautilus.ConnectionService): config = ServiceConfig from_service = ('service_one',) to_service = ('service_one',)
-
action_handler¶
-
from_service= None¶
-
name= 'connectionService'¶
-
to_service= None¶
-
nautilus.services.modelService module¶
-
class
nautilus.services.modelService.ModelService(model=None, **kwargs)[source]¶ Bases:
nautilus.services.service.ServiceThis service acts as the primary data store in your cloud. It manages the records of a single model by listening for actions that indicate a record mutation as well as emitting actions when the mutations have finished (whether successfully or not). The external API is automatically generated to match the given model.
Parameters: model (nautilus.BaseModel) – The nautilus model to manage. Example
import nautilus import nautilus.models as models class Model(models.BaseModel): name = models.fields.CharField() class ServiceConfig: database_url = 'sqlite:////tmp/models.db' class MyModelService(nautilus.ModelService): model = Model config = ServiceConfig
-
action_handler¶
-
get_models()[source]¶ Returns the models managed by this service.
Returns: the models managed by the service Return type: (list)
-
init_db()[source]¶ This function configures the database used for models to make the configuration parameters.
-
model= None¶
-
name= 'modelService'¶
-
nautilus.services.service module¶
-
class
nautilus.services.service.Service(name=None, schema=None, action_handler=None, config=None, auth=True)[source]¶ Bases:
objectThis is the base class for all services that are part of a nautilus cloud. This class provides basic functionalities such as registration, responding to actions, and predictable api endpoints.
Parameters: - action_handler (optional, function) – The callback function fired when an action is recieved. If None, the service does not connect to the action queue.
- config (optional, class) – A python class to use for configuring the service.
- name (string) – The name of the service. This will be used to register the service with the registry as act as the designator for a ServiceObjectType.
- schema (optional, graphql.core.type.GraphQLSchema) – The GraphQL schema which acts as a basis for the external API. If None, no endpoints are added to the service.
Example
import nautilus from nautilus.api.util import create_model_schema from nautilus.network import crud_handler import nautilus.models as models class Model(models.BaseModel): name = models.fields.CharField() class MyService(nautilus.Service): name = 'My Awesome Service' schema = create_model_schema(Model) action_handler = crud_handler(Model)
-
action_handler¶ alias of
ServiceActionHandler
-
add_http_endpoint(url, request_handler)[source]¶ This method provides a programatic way of added invidual routes to the http server.
Parameters: - url (str) – the url to be handled by the request_handler
- request_handler (nautilus.network.RequestHandler) – The request handler
-
api_request_handler_class¶ alias of
GraphQLRequestHandler
-
cleanup()[source]¶ This function is called when the service has finished running regardless of intentionally or not.
-
config= None¶
-
name= 'service'¶
-
classmethod
route(route, config=None)[source]¶ This method provides a decorator for adding endpoints to the http server.
Parameters: Example
import nautilus from nauilus.network.http import RequestHandler class MyService(nautilus.Service): # ... @MyService.route('/') class HelloWorld(RequestHandler): def get(self): return self.finish('hello world')
-
run(host='localhost', port=8000, shutdown_timeout=60.0, **kwargs)[source]¶ This function starts the service’s network intefaces.
Parameters: port (int) – The port for the http server.
-
schema= None¶
-
class
nautilus.services.service.ServiceActionHandler[source]¶ Bases:
nautilus.network.events.consumers.actions.ActionHandler
nautilus.services.serviceManager module¶
This module defines a small singleton that runs various scripts in the context of the service.