def start_realm(self, realm): """ Starts a realm on this router. :param realm: The realm to start. :type realm: instance of :class:`crossbar.worker.router.RouterRealm`. :returns: The router instance for the started realm. :rtype: instance of :class:`crossbar.router.session.CrossbarRouter` """ self.log.debug("CrossbarRouterFactory.start_realm(realm = {realm})", realm=realm) # get name of realm (an URI in general) # uri = realm.config['name'] assert (uri not in self._routers) # if configuration of realm contains a "store" item, set up a # realm store as appropriate .. store = None if 'store' in realm.config: store_config = realm.config['store'] if store_config['type'] == 'lmdb': # if LMDB is available, and a realm store / database is configured, # create an LMDB environment if not HAS_LMDB: raise Exception("LDMB not available") store = LmdbRealmStore(store_config) elif store_config['type'] == 'memory': store = MemoryRealmStore(store_config) else: raise Exception('logic error') # now create a router for the realm # options = RouterOptions( uri_check=self._options.uri_check, event_dispatching_chunk_size=self._options. event_dispatching_chunk_size, ) for arg in ['uri_check', 'event_dispatching_chunk_size']: if arg in realm.config.get('options', {}): setattr(options, arg, realm.config['options'][arg]) router = Router(self, realm, options, store=store) self._routers[uri] = router self.log.debug("Router created for realm '{uri}'", uri=uri) return router
def start_realm(self, realm): """ Starts a realm on this router. :param realm: The realm to start. :type realm: instance of :class:`crossbar.worker.router.RouterRealm`. :returns: The router instance for the started realm. :rtype: instance of :class:`crossbar.router.session.CrossbarRouter` """ self.log.debug("CrossbarRouterFactory.start_realm(realm = {realm})", realm=realm) # get name of realm (an URI in general) # uri = realm.config['name'] assert(uri not in self._routers) # if configuration of realm contains a "store" item, set up a # realm store as appropriate .. store = None if 'store' in realm.config: store_config = realm.config['store'] if store_config['type'] == 'lmdb': # if LMDB is available, and a realm store / database is configured, # create an LMDB environment if not HAS_LMDB: raise Exception("LDMB not available") store = LmdbRealmStore(store_config) elif store_config['type'] == 'memory': store = MemoryRealmStore(store_config) else: raise Exception('logic error') mqtt_payload_format = "opaque" if 'mqtt_payload_format' in realm.config: mqtt_payload_format = realm.config['mqtt_payload_format'] if mqtt_payload_format not in ["opaque", "json", "cbor"]: raise Exception("Not a valid mqtt_payload_format.") # now create a router for the realm # router = Router(self, realm, self._options, store=store, mqtt_payload_format=mqtt_payload_format) self._routers[uri] = router self.log.debug("Router created for realm '{uri}'", uri=uri) return router