storage

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: Apache-2.0, BSD-3-Clause, MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Policy

type Policy struct {
	ID                  primitive.ObjectID `bson:"_id"`
	Filename            string
	Name                string
	Group               string
	Version             string
	Rego                string
	Data                string
	DataConfig          string
	Locked              bool
	LastUpdate          time.Time
	NextDataRefreshTime time.Time
}

type PolicyChangeSubscriber

type PolicyChangeSubscriber interface {
	PolicyDataChange()
}

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

func New

func New(db *mongo.Client, dbname, collection string, logger *zap.Logger) (*Storage, error)

func (*Storage) AddPolicyChangeSubscriber

func (s *Storage) AddPolicyChangeSubscriber(subscriber PolicyChangeSubscriber)

func (*Storage) GetRefreshPolicies

func (s *Storage) GetRefreshPolicies(ctx context.Context) ([]*Policy, error)

func (*Storage) ListenPolicyDataChanges

func (s *Storage) ListenPolicyDataChanges(ctx context.Context) error

func (*Storage) Policy

func (s *Storage) Policy(ctx context.Context, group, name, version string) (*Policy, error)

func (*Storage) PostponeRefresh

func (s *Storage) PostponeRefresh(ctx context.Context, policies []*Policy) error

PostponeRefresh adds a refreshPostponePeriod Duration to each policy's nextDataRefreshTimeField in order to prevent concurrent data refresh

func (*Storage) SetPolicyLock

func (s *Storage) SetPolicyLock(ctx context.Context, group, name, version string, lock bool) error

func (*Storage) Transaction

func (s *Storage) Transaction(ctx context.Context, callback func(mCtx mongo.SessionContext) (interface{}, error)) (interface{}, error)

func (*Storage) UpdateNextRefreshTime

func (s *Storage) UpdateNextRefreshTime(ctx context.Context, p *Policy, nextDataRefreshTime time.Time) error

UpdateNextRefreshTime updates policy's data and nextDataRefreshTimeField fields

Jump to

Keyboard shortcuts

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