initial commit of MemoryOms class
This commit is contained in:
parent
545d38b93d
commit
d7cb7dc88d
35
mocha/oms/MemoryOms.py
Normal file
35
mocha/oms/MemoryOms.py
Normal file
@ -0,0 +1,35 @@
|
||||
from ..core import *
|
||||
from ..oms import Oms
|
||||
|
||||
class MemoryOms(Oms):
|
||||
|
||||
def __init__(self):
|
||||
self.__current_tenant = None
|
||||
self.__instances = dict()
|
||||
self.__tenants = dict()
|
||||
|
||||
def get_instance_by_key(self, key : InstanceKey):
|
||||
return self.__instances[key.to_tuple()]
|
||||
|
||||
# def get_instance_by_global_identifier(self, global_identifier : Guid):
|
||||
|
||||
def create_tenant(self, tenant_name : str):
|
||||
if tenant_name in self.__tenants:
|
||||
raise NameError("tenant with specified name already exists")
|
||||
|
||||
self.__tenants[tenant_name] = TenantReference(tenant_name, None)
|
||||
|
||||
def select_tenant(self, tenant : TenantReference):
|
||||
self.__current_tenant = tenant
|
||||
|
||||
def release_tenant(self):
|
||||
self.__current_tenant = None
|
||||
|
||||
def get_current_tenant(self):
|
||||
return self.__current_tenant
|
||||
|
||||
def get_tenant_by_name(self, tenant_name : str):
|
||||
if tenant_name in self.__tenants:
|
||||
return self.__tenants[tenant_name]
|
||||
|
||||
return None
|
||||
@ -1,3 +1,4 @@
|
||||
from .Oms import Oms
|
||||
from .DatabaseOms import DatabaseOms
|
||||
from .MemoryOms import MemoryOms
|
||||
from .MySQLDatabaseOms import MySQLDatabaseOms
|
||||
Loading…
x
Reference in New Issue
Block a user