Documentation ¶
Overview ¶
The (new) redis manager is intended to look like the officially supported memory manager. We take the tradeoff for slower inserts and deletions to make it easier to find applicable policies.
Index ¶
- Variables
- type RedisManager
- func (m *RedisManager) Create(policy Policy) error
- func (m *RedisManager) Delete(id string) error
- func (m *RedisManager) FindPoliciesForResource(resource string) (Policies, error)
- func (m *RedisManager) FindPoliciesForSubject(subject string) (Policies, error)
- func (m *RedisManager) FindRequestCandidates(r *Request) (Policies, error)
- func (m *RedisManager) Get(id string) (Policy, error)
- func (m *RedisManager) GetAll(limit int64, offset int64) (Policies, error)
- func (m *RedisManager) Update(policy Policy) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrPolicyExists = errors.New("Policy exists") ErrBadConversion = errors.New("Could not convert policy from redis") )
Functions ¶
This section is empty.
Types ¶
type RedisManager ¶
type RedisManager struct {
// contains filtered or unexported fields
}
RedisManager is a redis implementation of Manager to store policies persistently.
func NewRedisManager ¶
func NewRedisManager(db *redis.Client, keyPrefix string) *RedisManager
NewRedisManager initializes a new RedisManager with no policies
func (*RedisManager) Create ¶
func (m *RedisManager) Create(policy Policy) error
Create a new policy in Redis. It will create a single key for the policy itself, and for each subject and resource the policy will also exist in a hashmap.
func (*RedisManager) Delete ¶
func (m *RedisManager) Delete(id string) error
Delete removes a policy.
func (*RedisManager) FindPoliciesForResource ¶
func (m *RedisManager) FindPoliciesForResource(resource string) (Policies, error)
FindPoliciesForResource returns policies that could match the resource. It either returns a set of policies that apply to the resource, or a superset of it. If an error occurs, it returns nil and the error.
func (*RedisManager) FindPoliciesForSubject ¶
func (m *RedisManager) FindPoliciesForSubject(subject string) (Policies, error)
FindPoliciesForSubject returns policies that could match the subject. It either returns a set of policies that applies to the subject, or a superset of it. If an error occurs, it returns nil and the error.
func (*RedisManager) FindRequestCandidates ¶
func (m *RedisManager) FindRequestCandidates(r *Request) (Policies, error)
FindRequestCandidates returns candidates that could match the request object. It either returns a set that exactly matches the request, or a superset of it. If an error occurs, it returns nil and the error.
func (*RedisManager) Get ¶
func (m *RedisManager) Get(id string) (Policy, error)
Get retrieves a policy.
func (*RedisManager) GetAll ¶
func (m *RedisManager) GetAll(limit int64, offset int64) (Policies, error)
GetAll retrieves all policies. (Equivelant of db.keys + db.Mget)
func (*RedisManager) Update ¶
func (m *RedisManager) Update(policy Policy) error