package inmemory import ( "git.frostfs.info/TrueCloudLab/policy-engine/pkg/chain" "git.frostfs.info/TrueCloudLab/policy-engine/pkg/engine" "git.frostfs.info/TrueCloudLab/policy-engine/pkg/resource" ) type inmemory struct { router engine.ChainRouter morph engine.MorphRuleChainStorage local engine.LocalOverrideStorage } // NewInMemoryLocalOverrides returns new inmemory instance of chain storage with // local overrides manager. func NewInMemoryLocalOverrides() engine.LocalOverrideEngine { morph := NewInmemoryMorphRuleChainStorage() local := NewInmemoryLocalStorage() return &inmemory{ router: engine.NewDefaultChainRouterWithLocalOverrides(morph, local), morph: morph, local: local, } } // NewInMemory returns new inmemory instance of chain storage. func NewInMemory() engine.Engine { morph := NewInmemoryMorphRuleChainStorage() return &inmemory{ router: engine.NewDefaultChainRouter(morph), morph: morph, } } func (im *inmemory) LocalStorage() engine.LocalOverrideStorage { return im.local } func (im *inmemory) MorphRuleChainStorage() engine.MorphRuleChainStorage { return im.morph } func (im *inmemory) IsAllowed(name chain.Name, namespace string, r resource.Request) (status chain.Status, ruleFound bool, err error) { return im.router.IsAllowed(name, namespace, r) }