event

package
v0.0.0-...-9451de5 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2019 License: BSD-3-Clause Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotCancelable          = errors.New("event is not cancelable")
	ErrCancelAlreadyRequested = errors.New("event cancel already requested")
	ErrEventNotFound          = errors.New("event not found")
	ErrNoTarget               = ErrValidation("event target is mandatory")
	ErrNoKind                 = ErrValidation("event kind is mandatory")
	ErrNoOwner                = ErrValidation("event owner is mandatory")
	ErrNoOpts                 = ErrValidation("event opts is mandatory")
	ErrNoInternalKind         = ErrValidation("event internal kind is mandatory")
	ErrNoAllowed              = errors.New("event allowed is mandatory")
	ErrNoAllowedCancel        = errors.New("event allowed cancel is mandatory for cancelable events")
	ErrInvalidOwner           = ErrValidation("event owner must not be set on internal events")
	ErrInvalidKind            = ErrValidation("event kind must not be set on internal events")
	ErrInvalidTargetType      = errors.New("invalid event target type")

	OwnerTypeUser     = ownerType("user")
	OwnerTypeApp      = ownerType("app")
	OwnerTypeInternal = ownerType("internal")
	OwnerTypeToken    = ownerType("token")

	KindTypePermission = kindType("permission")
	KindTypeInternal   = kindType("internal")

	TargetTypeGlobal          = TargetType("global")
	TargetTypeApp             = TargetType("app")
	TargetTypeNode            = TargetType("node")
	TargetTypeContainer       = TargetType("container")
	TargetTypePool            = TargetType("pool")
	TargetTypeService         = TargetType("service")
	TargetTypeServiceInstance = TargetType("service-instance")
	TargetTypeServiceBroker   = TargetType("service-broker")
	TargetTypeTeam            = TargetType("team")
	TargetTypeUser            = TargetType("user")
	TargetTypeIaas            = TargetType("iaas")
	TargetTypeRole            = TargetType("role")
	TargetTypePlatform        = TargetType("platform")
	TargetTypePlan            = TargetType("plan")
	TargetTypeNodeContainer   = TargetType("node-container")
	TargetTypeInstallHost     = TargetType("install-host")
	TargetTypeEventBlock      = TargetType("event-block")
	TargetTypeCluster         = TargetType("cluster")
	TargetTypeVolume          = TargetType("volume")
	TargetTypeWebhook         = TargetType("webhook")
)

Functions

func AddBlock

func AddBlock(b *Block) error

func FormToCustomData

func FormToCustomData(form url.Values) []map[string]interface{}

func Initialize

func Initialize() error

func MarkAsRemoved

func MarkAsRemoved(target Target) error

func Migrate

func Migrate(query bson.M, cb func(*Event) error) error

func RemoveBlock

func RemoveBlock(id bson.ObjectId) error

func SetThrottling

func SetThrottling(spec ThrottlingSpec)

Types

type AllowedPermission

type AllowedPermission struct {
	Scheme   string
	Contexts []permTypes.PermissionContext `bson:",omitempty"`
}

func (*AllowedPermission) GetBSON

func (ap *AllowedPermission) GetBSON() (interface{}, error)

type Block

type Block struct {
	ID        bson.ObjectId `bson:"_id,omitempty"`
	StartTime time.Time
	EndTime   time.Time `bson:"endtime,omitempty"`
	KindName  string
	OwnerName string
	Target    Target `bson:"target,omitempty"`
	Reason    string
	Active    bool
}

func ListBlocks

func ListBlocks(active *bool) ([]Block, error)

func (*Block) Blocks

func (b *Block) Blocks(e *Event) bool

func (*Block) String

func (b *Block) String() string

type ErrActiveEventBlockNotFound

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

func (*ErrActiveEventBlockNotFound) Error

type ErrEventBlocked

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

func (ErrEventBlocked) Error

func (e ErrEventBlocked) Error() string

type ErrEventLocked

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

func (ErrEventLocked) Error

func (err ErrEventLocked) Error() string

type ErrThrottled

type ErrThrottled struct {
	Spec       *ThrottlingSpec
	Target     Target
	AllTargets bool
}

func (ErrThrottled) Error

func (err ErrThrottled) Error() string

type ErrValidation

type ErrValidation string

func (ErrValidation) Error

func (err ErrValidation) Error() string

type Event

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

func All

func All() ([]Event, error)

func GetByHexID

func GetByHexID(hexid string) (*Event, error)

func GetByID

func GetByID(id bson.ObjectId) (*Event, error)

func GetRunning

func GetRunning(target Target, kind string) (*Event, error)

func List

func List(filter *Filter) ([]Event, error)

func New

func New(opts *Opts) (*Event, error)

func NewInternal

func NewInternal(opts *Opts) (*Event, error)

func (*Event) Abort

func (e *Event) Abort() error

func (*Event) AckCancel

func (e *Event) AckCancel() (bool, error)

func (*Event) CancelableContext

func (e *Event) CancelableContext(ctx context.Context) (context.Context, context.CancelFunc)

func (*Event) Done

func (e *Event) Done(evtErr error) error

func (*Event) DoneCustomData

func (e *Event) DoneCustomData(evtErr error, customData interface{}) error

func (*Event) EndData

func (e *Event) EndData(value interface{}) error

func (*Event) GetLogWriter

func (e *Event) GetLogWriter() io.Writer

func (*Event) Init

func (e *Event) Init()

func (*Event) Logf

func (e *Event) Logf(format string, params ...interface{})

func (*Event) OtherData

func (e *Event) OtherData(value interface{}) error

func (*Event) RawInsert

func (e *Event) RawInsert(start, other, end interface{}) error

func (*Event) SetLogWriter

func (e *Event) SetLogWriter(w io.Writer)

func (*Event) SetOtherCustomData

func (e *Event) SetOtherCustomData(data interface{}) error

func (*Event) StartData

func (e *Event) StartData(value interface{}) error

func (*Event) String

func (e *Event) String() string

func (*Event) TryCancel

func (e *Event) TryCancel(reason, owner string) error

func (*Event) Write

func (e *Event) Write(data []byte) (int, error)

type ExtraTarget

type ExtraTarget struct {
	Target Target
	Lock   bool
}

type Filter

type Filter struct {
	Target         Target
	KindType       kindType
	KindNames      []string `form:"-"`
	OwnerType      ownerType
	OwnerName      string
	Since          time.Time
	Until          time.Time
	Running        *bool
	IncludeRemoved bool
	ErrorOnly      bool
	Raw            bson.M
	AllowedTargets []TargetFilter
	Permissions    []permission.Permission

	Limit int
	Skip  int
	Sort  string
}

func (*Filter) LoadKindNames

func (f *Filter) LoadKindNames(form map[string][]string)

func (*Filter) PruneUserValues

func (f *Filter) PruneUserValues()

type Kind

type Kind struct {
	Type kindType
	Name string
}

func GetKinds

func GetKinds() ([]Kind, error)

func (Kind) String

func (k Kind) String() string

type Opts

type Opts struct {
	Target        Target
	ExtraTargets  []ExtraTarget
	Kind          *permission.PermissionScheme
	InternalKind  string
	Owner         auth.Token
	RawOwner      Owner
	CustomData    interface{}
	DisableLock   bool
	Cancelable    bool
	Allowed       AllowedPermission
	AllowedCancel AllowedPermission
}

type Owner

type Owner struct {
	Type ownerType
	Name string
}

func (Owner) String

func (o Owner) String() string

type Target

type Target struct {
	Type  TargetType
	Value string
}

func (Target) GetBSON

func (id Target) GetBSON() (interface{}, error)

func (Target) IsValid

func (id Target) IsValid() bool

func (Target) String

func (id Target) String() string

type TargetFilter

type TargetFilter struct {
	Type   TargetType
	Values []string
}

type TargetType

type TargetType string

func GetTargetType

func GetTargetType(t string) (TargetType, error)

type ThrottlingSpec

type ThrottlingSpec struct {
	TargetType TargetType    `json:"target-type"`
	KindName   string        `json:"kind-name"`
	Max        int           `json:"limit"`
	Time       time.Duration `json:"window"`
	AllTargets bool          `json:"all-targets"`
	WaitFinish bool          `json:"wait-finish"`
}

func (*ThrottlingSpec) UnmarshalJSON

func (d *ThrottlingSpec) UnmarshalJSON(data []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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