from fireteam.services import get_service_map from fireteam.worker.worker import Worker from fireteam.worker.serviceprovider import ServiceProvider # Automatically start up with all services for the time being service_names = list(get_service_map()) def make_worker(service_names): return Worker(service_names) def make_wsgi_app(service_names): return ServiceProvider(service_names) if __name__ == "__main__": # service validation # Erlang layer should probably specify a checksum of the api configs it is # using so there is no risk of the workers using different version of # these services. # register services # TODO: should this be configuration based? Or should all workers load all # potentially required services for the cluster; certain titles might not # need all the services and if it is a dedicated cluster we don't need to # register these. # Likely needs to be configuration based or this specific worker, the # worker then advertises back up the chain what it supports. worker = make_worker(service_names) #sys.exit(worker.main()) # for local debugging import argparse from fireteam.utils import cmdline from fireteam.db import DBSession parser = argparse.ArgumentParser() # following 3 args so can test browser-accessible services cmdline.add_env_argument(parser) cmdline.add_realm_argument(parser) cmdline.add_app_argument(parser) parser.add_argument("--host", default="127.0.0.1") parser.add_argument("--port", default=5000, type=int) with DBSession().contextbound(): args = parser.parse_args() worker.run_wsgi_server(host=args.host, port=args.port, env=args.env, realm=args.realm, application=args.app) else: # execute as a WSGI application module application = make_wsgi_app(service_names) # An incoming API call will have the following parameters: # - Web Service: # -- Application ID # -- Service ID (?) # -- API Call ID (?) # -- Query parameters # - Native Call: # -- Application ID # -- Service ID # -- API Call ID # -- Query parameters # # Web Service: parse endpoint + method, turns into a service id/api call # id mapping # # URL routing for webservices is done in the erlang core, allowing for # early rejection URL routing should include authorization checks # Worker has two entry points: ## Web3 request ## - results in a Web3 response, to be sent back via web service ## Native request ## - results in a native response, bit buffer to be sent over TCP channel