watcher

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidRelationTupleString = fmt.Errorf("the RelationTuple string is malformed")
View Source
var ErrInvalidSubjectSetString = fmt.Errorf("the provided SubjectSet string is malformed")

Functions

This section is empty.

Types

type AccessWatcher

type AccessWatcher struct {
	watchpb.UnimplementedWatchServiceServer
	// contains filtered or unexported fields
}

func NewAccessWatcher

func NewAccessWatcher(opts ...AccessWatcherOption) (*AccessWatcher, error)

func (*AccessWatcher) Close

func (w *AccessWatcher) Close(ctx context.Context) error

func (*AccessWatcher) Watch

type AccessWatcherOption

type AccessWatcherOption func(*AccessWatcher)

func WithChangelogDatastore

func WithChangelogDatastore(ds ChangelogDatastore) AccessWatcherOption

type ChangelogDatastore

type ChangelogDatastore interface {
	GetRelationTupleChanges(ctx context.Context, namespaces []string, timestamp time.Time) (ChangelogIterator, error)
}

type ChangelogEntry

type ChangelogEntry struct {
	Namespace     string
	Operation     string
	RelationTuple *InternalRelationTuple
	Timestamp     time.Time
}

type ChangelogIterator

type ChangelogIterator interface {

	// Next prepares the next changelog entry for reading. It returns true
	// if there is another entry and false if no more entries are available.
	Next() bool

	// Value returns the current most changelog entry that the iterator is
	// iterating over.
	Value() (*ChangelogEntry, error)
}

ChangelogIterator is used to iterate over changelog entries as they are yielded.

type InternalRelationTuple

type InternalRelationTuple struct {
	Namespace string  `json:"namespace"`
	Object    string  `json:"object"`
	Relation  string  `json:"relation"`
	Subject   Subject `json:"subject"`
}

func RelationTupleFromString

func RelationTupleFromString(s string) (*InternalRelationTuple, error)

func (*InternalRelationTuple) String

func (r *InternalRelationTuple) String() string

String returns r as a relation tuple in string format.

func (*InternalRelationTuple) ToProto

ToProto serializes r in it's equivalent protobuf format.

type Subject

type Subject interface {
	json.Marshaler

	String() string
	FromString(string) (Subject, error)
	Equals(interface{}) bool
	ToProto() *watchpb.Subject
}

func SubjectFromString

func SubjectFromString(s string) (Subject, error)

SubjectFromString parses the string s and returns a Subject - either a SubjectSet or an explicit SubjectID.

type SubjectID

type SubjectID struct {
	ID string `json:"id"`
}

func (*SubjectID) Equals

func (s *SubjectID) Equals(v interface{}) bool

func (*SubjectID) FromString

func (s *SubjectID) FromString(str string) (Subject, error)

func (SubjectID) MarshalJSON

func (s SubjectID) MarshalJSON() ([]byte, error)

func (*SubjectID) String

func (s *SubjectID) String() string

func (*SubjectID) ToProto

func (s *SubjectID) ToProto() *watchpb.Subject

type SubjectSet

type SubjectSet struct {
	Namespace string `json:"namespace"`
	Object    string `json:"object"`
	Relation  string `json:"relation"`
}

func (*SubjectSet) Equals

func (s *SubjectSet) Equals(v interface{}) bool

func (*SubjectSet) FromString

func (s *SubjectSet) FromString(str string) (Subject, error)

func (SubjectSet) MarshalJSON

func (s SubjectSet) MarshalJSON() ([]byte, error)

func (*SubjectSet) String

func (s *SubjectSet) String() string

func (*SubjectSet) ToProto

func (s *SubjectSet) ToProto() *watchpb.Subject

Directories

Path Synopsis
datastores

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL