Exemplo n.º 1
0
        /// <summary>
        /// Load OPA policy from a .wasm file on disk. Incurs compilation penalty.
        /// </summary>
        /// <param name="fileName"></param>
        public OpaPolicy(string fileName)
        {
            using var module = new OpaModule();
            var wasmModule = module.Load(fileName);

            SetupHost(module, wasmModule);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Load OPA policy from an in-memory byte[] (eg Cache or other non-disk location). Incurs compilation penalty.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="content"></param>
        public OpaPolicy(string name, byte[] content)
        {
            using var module = new OpaModule();
            var wasmModule = module.Load(name, content);

            SetupHost(module, wasmModule);
        }
Exemplo n.º 3
0
 private void SetupHost(OpaModule module, Module wasmModule)
 {
     _host = module.CreateHost();
     BuildHost();
     Initialize(wasmModule);
 }
Exemplo n.º 4
0
 /// <summary>
 /// This ctor is intended for scenarios where you want to cache a precompiled WASM module
 /// </summary>
 /// <param name="module"></param>
 /// <param name="wasmModule"></param>
 public OpaPolicy(OpaModule module, Module wasmModule)
 {
     SetupHost(module, wasmModule);
 }