trigger

package
v0.0.0-...-f7ae98d Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RegistrySingleton = Registry{
	Registry: *registry.NewRegistry("trigger"),
}

global singleton

Functions

This section is empty.

Types

type AbstractTrigger

type AbstractTrigger struct {
	ID              string
	Logger          logger.Logger
	WorkerAllocator worker.Allocator
	Class           string
	Kind            string
	Statistics      Statistics
}

AbstractTrigger implements common trigger operations

func (*AbstractTrigger) AllocateWorkerAndSubmitEvent

func (at *AbstractTrigger) AllocateWorkerAndSubmitEvent(event nuclio.Event,
	functionLogger logger.Logger,
	timeout time.Duration) (response interface{}, submitError error, processError error)

AllocateWorkerAndSubmitEvent submits event to allocated worker

func (*AbstractTrigger) AllocateWorkerAndSubmitEvents

func (at *AbstractTrigger) AllocateWorkerAndSubmitEvents(events []nuclio.Event,
	functionLogger logger.Logger,
	timeout time.Duration) (responses []interface{}, submitError error, processErrors []error)

AllocateWorkerAndSubmitEvents submits multiple events to an allocated worker

func (*AbstractTrigger) GetClass

func (at *AbstractTrigger) GetClass() string

GetClass returns the class

func (*AbstractTrigger) GetID

func (at *AbstractTrigger) GetID() string

GetID returns user given ID for this trigger

func (*AbstractTrigger) GetKind

func (at *AbstractTrigger) GetKind() string

GetKind return the kind

func (*AbstractTrigger) GetStatistics

func (at *AbstractTrigger) GetStatistics() *Statistics

GetStatistics returns trigger statistics

func (*AbstractTrigger) GetWorkers

func (at *AbstractTrigger) GetWorkers() []*worker.Worker

GetWorkers returns the list of workers

func (*AbstractTrigger) HandleSubmitPanic

func (at *AbstractTrigger) HandleSubmitPanic(workerInstance *worker.Worker,
	submitError *error)

HandleSubmitPanic handles a panic when submitting to worker

func (*AbstractTrigger) Initialize

func (at *AbstractTrigger) Initialize() error

Initialize performs post creation initializations

func (*AbstractTrigger) SubmitEventToWorker

func (at *AbstractTrigger) SubmitEventToWorker(functionLogger logger.Logger,
	workerInstance *worker.Worker,
	event nuclio.Event) (response interface{}, processError error)

SubmitEventToWorker submits events to worker and returns response

func (*AbstractTrigger) UpdateStatistics

func (at *AbstractTrigger) UpdateStatistics(success bool)

UpdateStatistics updates the trigger statistics

type Configuration

type Configuration struct {
	functionconfig.Trigger

	// the runtime configuration, for reference
	RuntimeConfiguration *runtime.Configuration

	// a unique trigger ID
	ID string
}

func NewConfiguration

func NewConfiguration(ID string,
	triggerConfiguration *functionconfig.Trigger,
	runtimeConfiguration *runtime.Configuration) *Configuration

type Creator

type Creator interface {

	// Create creates a trigger instance
	Create(logger.Logger, string, *functionconfig.Trigger, *runtime.Configuration, map[string]worker.Allocator) (Trigger, error)
}

Creator creates a trigger instance

type Factory

type Factory struct{}

func (*Factory) GetWorkerAllocator

func (f *Factory) GetWorkerAllocator(workerAllocatorName string,
	namedWorkerAllocators map[string]worker.Allocator,
	workerAllocatorCreator func() (worker.Allocator, error)) (worker.Allocator, error)

type Registry

type Registry struct {
	registry.Registry
}

func (*Registry) NewTrigger

func (r *Registry) NewTrigger(logger logger.Logger,
	kind string,
	name string,
	triggerConfiguration *functionconfig.Trigger,
	runtimeConfiguration *runtime.Configuration,
	namedWorkerAllocators map[string]worker.Allocator) (Trigger, error)

type Secret

type Secret struct {
	Contents  string
	SecretRef SecretRef
}

type SecretRef

type SecretRef struct {
	Name string
	Key  string
}

type Statistics

type Statistics struct {
	EventsHandleSuccessTotal uint64
	EventsHandleFailureTotal uint64
}

func (*Statistics) DiffFrom

func (s *Statistics) DiffFrom(prev *Statistics) Statistics

type Trigger

type Trigger interface {

	// Initialize performs post creation initializations
	Initialize() error

	// start creating events from a given checkpoint (nil - no checkpoint)
	Start(checkpoint functionconfig.Checkpoint) error

	// stop creating events. returns the current checkpoint
	Stop(force bool) (functionconfig.Checkpoint, error)

	// get the user given ID for this trigger
	GetID() string

	// get the class of source (sync, async, etc)
	GetClass() string

	// get specific kind of source (http, rabbit mq, etc)
	GetKind() string

	// get the configuration
	GetConfig() map[string]interface{}

	// get statistics
	GetStatistics() *Statistics

	// get direct access to workers for things like housekeeping / management
	// TODO: locks and such when relevant
	GetWorkers() []*worker.Worker
}

Jump to

Keyboard shortcuts

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