HandlerManager

This module contains the necessary tools to discover and load the handlers for serving HTTPS

class DIRAC.Core.Tornado.Server.HandlerManager.HandlerManager(services, endpoints)

Bases: object

This utility class allows to load the handlers, generate the appropriate route, and discover the handlers based on the CS. In order for a service to be considered as using HTTPS, it must have protocol = https as an option.

Each of the Handler will have one associated route to it:

  • Directly specified as DEFAULT_LOCATION in the handler module

  • automatically deduced from the module name, of the form System/Component (e.g. DataManagement/FileCatalog)

__init__(services, endpoints)

Initialization function, you can set False for both arguments to prevent automatic discovery of handlers and use loadServicesHandlers() to load your handlers or loadEndpointsHandlers()

Parameters:
  • services (bool or list) – List of service handlers to load. If True, loads all services from CS

  • endpoints (bool or list) – List of endpoint handlers to load. If True, loads all endpoints from CS

discoverHandlers(handlerInstance)

Force the discovery of URL, automatic call when we try to get handlers for the first time. You can disable the automatic call with autoDiscovery=False at initialization

Parameters:

handlerInstance (str) – handler instance, the name of the section in some system section e.g.:: Services, APIs

Returns:

list

getHandlersDict()

Return all handler dictionary

Returns:

dictionary with service name as key (“System/Service”) and tornado.web.url objects as value for ‘URLs’ key and port as value for ‘Port’ key

getHandlersURLs()

Get all handler for usage in Tornado, as a list of tornado.web.url

Returns:

a list of URL (not the string with “https://…” but the tornado object) see http://www.tornadoweb.org/en/stable/web.html#tornado.web.URLSpec

loadEndpointsHandlers(endpoints=None)

Load endpoints

Parameters:

endpoints (bool or list) – List of endpoint handlers to load. Default value set at initialization If True, loads all endpoints from CS

Returns:

S_OK()/S_ERROR()

loadServicesHandlers(services=None)

Load services

Parameters:

services (bool or list) – List of service handlers to load. Default value set at initialization If True, loads all services from CS

Returns:

S_OK()/S_ERROR()