Documentation ¶
Index ¶
- Constants
- func IsNotFound(err error) bool
- func LoadPolicies(bufs map[string][]byte) (map[string]*ast.Module, error)
- type Bindings
- func (b *Bindings) Copy() *Bindings
- func (b *Bindings) Equal(other *Bindings) bool
- func (b *Bindings) Get(k ast.Value) ast.Value
- func (b *Bindings) Hash() int
- func (b *Bindings) Iter(iter func(ast.Value, ast.Value) bool) bool
- func (b *Bindings) Put(k, v ast.Value)
- func (b *Bindings) String() string
- func (b *Bindings) Update(other *Bindings) *Bindings
- type DataStore
- func (ds *DataStore) Get(path []interface{}) (interface{}, error)
- func (ds *DataStore) GetRef(ref ast.Ref) (interface{}, error)
- func (ds *DataStore) MakePath(path []interface{}) error
- func (ds *DataStore) MustGet(path []interface{}) interface{}
- func (ds *DataStore) Patch(op PatchOp, path []interface{}, value interface{}) error
- func (ds *DataStore) String() string
- type ErrCode
- type Error
- type Index
- type Indices
- type PatchOp
- type PolicyStore
- func (p *PolicyStore) Add(id string, mod *ast.Module, raw []byte, persist bool) error
- func (p *PolicyStore) Get(id string) (*ast.Module, error)
- func (p *PolicyStore) GetRaw(id string) ([]byte, error)
- func (p *PolicyStore) List() map[string]*ast.Module
- func (p *PolicyStore) Open(f func(map[string][]byte) (map[string]*ast.Module, error)) error
- func (p *PolicyStore) Remove(id string) error
Constants ¶
const ( AddOp PatchOp = iota RemoveOp = iota ReplaceOp = iota )
Patch supports add, remove, and replace operations.
Variables ¶
This section is empty.
Functions ¶
func IsNotFound ¶
IsNotFound returns true if this error is a NotFoundErr
Types ¶
type Bindings ¶
type Bindings struct {
// contains filtered or unexported fields
}
Bindings represents a mapping between key/value pairs. The key/value pairs are AST values contained in expressions. Insertion of a key/value pair represents unification of the two values.
func (*Bindings) Equal ¶
Equal returns true if these bindings equal the other bindings. Two bindings are equal if they contain the same key/value pairs.
type DataStore ¶
type DataStore struct { Indices *Indices // contains filtered or unexported fields }
DataStore is the backend containing rule references and data.
func NewDataStoreFromJSONObject ¶
NewDataStoreFromJSONObject returns a new DataStore containing the supplied documents. This is mostly for test purposes.
func (*DataStore) Get ¶
Get returns the value in Storage referenced by path. If the lookup fails, an error is returned with a message indicating why the failure occurred.
func (*DataStore) GetRef ¶
GetRef returns the value in Storage referred to by the reference. This is a convienence function.
func (*DataStore) MakePath ¶
MakePath ensures the specified path exists by creating elements as necessary.
func (*DataStore) MustGet ¶
func (ds *DataStore) MustGet(path []interface{}) interface{}
MustGet returns the value in Storage reference by path. If the lookup fails, the function will panic.
type ErrCode ¶
type ErrCode int
ErrCode represents the collection of error types that can be returned by Storage.
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
Index contains a mapping of values to bindings.
func (*Index) Add ¶
Add updates the index to include new bindings for the value. If the bindings already exist for the value, no change is made.
type Indices ¶
type Indices struct {
// contains filtered or unexported fields
}
Indices contains a mapping of non-ground references to values to sets of bindings.
+------+------------------------------------+ | ref1 | val1 | bindings-1, bindings-2, ... | | +------+-----------------------------+ | | val2 | bindings-m, bindings-m, ... | | +------+-----------------------------+ | | .... | ... | +------+------+-----------------------------+ | ref2 | .... | ... | +------+------+-----------------------------+ | ... | +-------------------------------------------+
The "value" is the data value stored at the location referred to by the ground reference obtained by plugging bindings into the non-ground reference that is the index key.
func (*Indices) Build ¶
Build initializes the references' index by walking the store for the reference and creating the index that maps values to bindings.
type PolicyStore ¶
type PolicyStore struct {
// contains filtered or unexported fields
}
PolicyStore provides a storage abstraction for policy definitions and modules.
func NewPolicyStore ¶
func NewPolicyStore(store *DataStore, policyDir string) *PolicyStore
NewPolicyStore returns an empty PolicyStore.
func (*PolicyStore) Add ¶
Add inserts the policy module into the store. If an existing policy module exists with the same ID, it is overwritten. If persist is false, then the policy will not be persisted.
func (*PolicyStore) Get ¶
func (p *PolicyStore) Get(id string) (*ast.Module, error)
Get returns the policy module for id.
func (*PolicyStore) GetRaw ¶
func (p *PolicyStore) GetRaw(id string) ([]byte, error)
GetRaw returns the raw content of the module for id.
func (*PolicyStore) List ¶
func (p *PolicyStore) List() map[string]*ast.Module
List returns all of the modules.
func (*PolicyStore) Open ¶
Open initializes the policy store.
This should be called on startup to load policies from persistent storage. The callback function "f" will be invoked with the buffers representing the persisted policies. The callback should return the compiled version of the policies so that they can be installed into the data store.
func (*PolicyStore) Remove ¶
func (p *PolicyStore) Remove(id string) error
Remove removes the policy module for id.