approvals

package
v0.0.0-...-c5ab296 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2019 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ApprovalsPrefix = "approvals"
)

Approvals cache prefix

Variables

View Source
var (
	ErrApprovalAlreadyExists = errors.New("approval already exists")
)

Approvals related errors

Functions

This section is empty.

Types

type DefaultManager

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

DefaultManager - default manager implementation

func New

func New(opts *Opts) *DefaultManager

New create new instance of default manager

func (*DefaultManager) Approve

func (m *DefaultManager) Approve(identifier, voter string) (*types.Approval, error)

Approve - increase VotesReceived by 1 and returns updated version

func (*DefaultManager) Archive

func (m *DefaultManager) Archive(identifier string) error

func (*DefaultManager) Create

func (m *DefaultManager) Create(r *types.Approval) error

Create - creates new approval request and publishes to all subscribers

func (*DefaultManager) Delete

func (m *DefaultManager) Delete(approval *types.Approval) error

Delete - delete specified approval

func (*DefaultManager) Get

func (m *DefaultManager) Get(identifier string) (*types.Approval, error)

Get - get specified, not archived approval

func (*DefaultManager) List

func (m *DefaultManager) List() ([]*types.Approval, error)

List - list not archived approvals (for expiration service)

func (*DefaultManager) Reject

func (m *DefaultManager) Reject(identifier string) (*types.Approval, error)

Reject - rejects approval (marks rejected=true), approval will not be valid even if it collects required votes

func (*DefaultManager) StartExpiryService

func (m *DefaultManager) StartExpiryService(ctx context.Context) error

StartExpiryService - starts approval expiry service which deletes approvals that already reached their deadline

func (*DefaultManager) Subscribe

func (m *DefaultManager) Subscribe(ctx context.Context) (<-chan *types.Approval, error)

Subscribe - subscribe for approval events

func (*DefaultManager) SubscribeApproved

func (m *DefaultManager) SubscribeApproved(ctx context.Context) (<-chan *types.Approval, error)

SubscribeApproved - subscribe for approved update requests

func (*DefaultManager) Update

func (m *DefaultManager) Update(r *types.Approval) error

Update - update approval

type Manager

type Manager interface {
	// Subscribe for approval request events, subscriber should provide
	// its name. Indented to be used by extensions that collect
	// approvals
	Subscribe(ctx context.Context) (<-chan *types.Approval, error)

	// SubscribeApproved - is used to get approved events by the manager
	SubscribeApproved(ctx context.Context) (<-chan *types.Approval, error)

	// request approval for deployment/release/etc..
	Create(r *types.Approval) error
	// Update whole approval object
	Update(r *types.Approval) error

	// Increases Approval votes by 1
	Approve(identifier, voter string) (*types.Approval, error)
	// Rejects Approval
	Reject(identifier string) (*types.Approval, error)

	Get(identifier string) (*types.Approval, error)
	List() ([]*types.Approval, error)
	Delete(*types.Approval) error
	Archive(identifier string) error

	StartExpiryService(ctx context.Context) error
}

Manager is used to manage updates

type Opts

type Opts struct {
	Store store.Store
}

Jump to

Keyboard shortcuts

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