worker

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2022 License: Apache-2.0 Imports: 20 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ScheduleKeyToTopicName added in v0.13.0

func ScheduleKeyToTopicName(key string) string

ScheduleKeyToTopicName - converts a schedule description to a name for a topic e.g. "Prune Customer Orders" -> "prune-customer-orders"

Types

type Adapter added in v0.18.0

type Adapter interface {
	HandleEvent(ctx context.Context, trigger *triggers.Event) error
	HandleHttpRequest(ctx context.Context, trigger *triggers.HttpRequest) (*triggers.HttpResponse, error)
}

Adapter - An interface for defining the delivery of events

type Delegate added in v0.18.0

type Delegate interface {
	HandlesHttpRequest(trigger *triggers.HttpRequest) bool
	HandlesEvent(trigger *triggers.Event) bool
}

type FaasWorker

type FaasWorker struct {
	Adapter
}

FaasWorker Worker representation for a Nitric FaaS function using gRPC

func NewFaasWorker

func NewFaasWorker(adapter Adapter) *FaasWorker

NewFaasWorker - Create a new FaaS worker

func (*FaasWorker) HandlesEvent added in v0.18.0

func (s *FaasWorker) HandlesEvent(trigger *triggers.Event) bool

func (*FaasWorker) HandlesHttpRequest added in v0.18.0

func (s *FaasWorker) HandlesHttpRequest(trigger *triggers.HttpRequest) bool

type GetWorkerOptions added in v0.13.0

type GetWorkerOptions struct {
	Http   *triggers.HttpRequest
	Event  *triggers.Event
	Filter func(w Worker) bool
}

type GrpcAdapter added in v0.18.0

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

func NewGrpcAdapter added in v0.18.0

func NewGrpcAdapter(stream v1.FaasService_TriggerStreamServer) *GrpcAdapter

func (*GrpcAdapter) HandleEvent added in v0.18.0

func (s *GrpcAdapter) HandleEvent(ctx context.Context, trigger *triggers.Event) error

func (*GrpcAdapter) HandleHttpRequest added in v0.18.0

func (s *GrpcAdapter) HandleHttpRequest(ctx context.Context, trigger *triggers.HttpRequest) (*triggers.HttpResponse, error)

func (*GrpcAdapter) Start added in v0.18.0

func (gwb *GrpcAdapter) Start(errchan chan error)

type HttpWorker

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

A Nitric HTTP worker

func NewHttpWorker

func NewHttpWorker(address string) (*HttpWorker, error)

Creates a new HttpWorker Will wait to ensure that the provided address is dialable before proceeding

func (*HttpWorker) HandleEvent

func (h *HttpWorker) HandleEvent(ctx context.Context, trigger *triggers.Event) error

HandleEvent - Handles an event from a subscription by converting it to an HTTP request.

func (*HttpWorker) HandleHttpRequest

func (h *HttpWorker) HandleHttpRequest(ctx context.Context, trigger *triggers.HttpRequest) (*triggers.HttpResponse, error)

HandleHttpRequest - Handles an HTTP request by forwarding it as an HTTP request.

func (*HttpWorker) HandlesEvent added in v0.13.0

func (s *HttpWorker) HandlesEvent(trigger *triggers.Event) bool

func (*HttpWorker) HandlesHttpRequest added in v0.13.0

func (s *HttpWorker) HandlesHttpRequest(trigger *triggers.HttpRequest) bool

type InstrumentedWorkerPool added in v0.21.0

type InstrumentedWorkerPool struct {
	WorkerPool
	Wrapper WrappedWorkerFn
}

func (*InstrumentedWorkerPool) AddWorker added in v0.21.0

func (iwp *InstrumentedWorkerPool) AddWorker(w Worker) error

AddWorker - Adds the given worker to this pool

type ProcessPool

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

ProcessPool - A worker pool that represent co-located processes

func (*ProcessPool) AddWorker

func (p *ProcessPool) AddWorker(wrkr Worker) error

AddWorker - Adds the given worker to this pool

func (*ProcessPool) GetMaxWorkers

func (p *ProcessPool) GetMaxWorkers() int

GetMaxWorkers - return the maximum number of workers for this pool

func (*ProcessPool) GetMinWorkers

func (p *ProcessPool) GetMinWorkers() int

GetMinWorkers - return the minimum number of workers for this pool

func (*ProcessPool) GetWorker

func (p *ProcessPool) GetWorker(opts *GetWorkerOptions) (Worker, error)

GetWorker - Retrieves a worker from this pool

func (*ProcessPool) GetWorkerCount

func (p *ProcessPool) GetWorkerCount() int

func (*ProcessPool) GetWorkers added in v0.13.0

func (p *ProcessPool) GetWorkers(opts *GetWorkerOptions) []Worker

GetWorkers - return a slice of all workers matching the input options. useful for retrieving a list of all topic subscribers (for example)

func (*ProcessPool) Monitor

func (p *ProcessPool) Monitor() error

Monitor - Blocks the current thread to supervise this worker pool

func (*ProcessPool) RemoveWorker

func (p *ProcessPool) RemoveWorker(wrkr Worker) error

RemoveWorker - Removes the given worker from this pool

func (*ProcessPool) WaitForMinimumWorkers

func (p *ProcessPool) WaitForMinimumWorkers(timeout int) error

WaitForMinimumWorkers - Waits for the configured minimum number of workers to be available in this pool

type ProcessPoolOptions

type ProcessPoolOptions struct {
	MinWorkers int
	MaxWorkers int
}

type RouteWorker added in v0.13.0

type RouteWorker struct {
	Adapter
	// contains filtered or unexported fields
}

RouteWorker - Worker representation for an http api route handler

func NewRouteWorker added in v0.13.0

func NewRouteWorker(adapter Adapter, opts *RouteWorkerOptions) *RouteWorker

Package private method Only a pool may create a new faas worker

func (*RouteWorker) Api added in v0.13.0

func (s *RouteWorker) Api() string

Api - Retrieve the name of the API this route worker was registered for

func (*RouteWorker) HandleEvent added in v0.13.0

func (s *RouteWorker) HandleEvent(ctx context.Context, trigger *triggers.Event) error

func (*RouteWorker) HandleHttpRequest added in v0.13.0

func (s *RouteWorker) HandleHttpRequest(ctx context.Context, trigger *triggers.HttpRequest) (*triggers.HttpResponse, error)

func (*RouteWorker) HandlesEvent added in v0.13.0

func (s *RouteWorker) HandlesEvent(trigger *triggers.Event) bool

func (*RouteWorker) HandlesHttpRequest added in v0.13.0

func (s *RouteWorker) HandlesHttpRequest(trigger *triggers.HttpRequest) bool

type RouteWorkerOptions added in v0.13.0

type RouteWorkerOptions struct {
	Api     string
	Path    string
	Methods []string
}

type ScheduleWorker added in v0.13.0

type ScheduleWorker struct {
	Adapter
	// contains filtered or unexported fields
}

RouteWorker - Worker representation for an http api route handler

func NewScheduleWorker added in v0.13.0

func NewScheduleWorker(adapter Adapter, opts *ScheduleWorkerOptions) *ScheduleWorker

Package private method Only a pool may create a new faas worker

func (*ScheduleWorker) HandleHttpRequest added in v0.13.0

func (s *ScheduleWorker) HandleHttpRequest(ctx context.Context, trigger *triggers.HttpRequest) (*triggers.HttpResponse, error)

func (*ScheduleWorker) HandlesEvent added in v0.13.0

func (s *ScheduleWorker) HandlesEvent(trigger *triggers.Event) bool

func (*ScheduleWorker) HandlesHttpRequest added in v0.13.0

func (s *ScheduleWorker) HandlesHttpRequest(trigger *triggers.HttpRequest) bool

func (*ScheduleWorker) Key added in v0.13.0

func (s *ScheduleWorker) Key() string

type ScheduleWorkerOptions added in v0.13.0

type ScheduleWorkerOptions struct {
	Key string
}

type SubscriptionWorker added in v0.13.0

type SubscriptionWorker struct {
	Delegate
	Adapter
	// contains filtered or unexported fields
}

RouteWorker - Worker representation for an http api route handler

func NewSubscriptionWorker added in v0.13.0

func NewSubscriptionWorker(adapter Adapter, opts *SubscriptionWorkerOptions) *SubscriptionWorker

Package private method Only a pool may create a new faas worker

func (*SubscriptionWorker) HandleHttpRequest added in v0.13.0

func (s *SubscriptionWorker) HandleHttpRequest(ctx context.Context, trigger *triggers.HttpRequest) (*triggers.HttpResponse, error)

func (*SubscriptionWorker) HandlesEvent added in v0.13.0

func (s *SubscriptionWorker) HandlesEvent(trigger *triggers.Event) bool

func (*SubscriptionWorker) HandlesHttpRequest added in v0.13.0

func (s *SubscriptionWorker) HandlesHttpRequest(trigger *triggers.HttpRequest) bool

func (*SubscriptionWorker) Topic added in v0.13.0

func (s *SubscriptionWorker) Topic() string

type SubscriptionWorkerOptions added in v0.13.0

type SubscriptionWorkerOptions struct {
	Topic string
}

type UnimplementedWorker

type UnimplementedWorker struct{}

func (*UnimplementedWorker) HandleEvent

func (*UnimplementedWorker) HandleEvent(trigger *triggers.Event) error

func (*UnimplementedWorker) HandleHttpRequest

func (*UnimplementedWorker) HandleHttpRequest(trigger *triggers.HttpRequest) (*triggers.HttpResponse, error)

func (*UnimplementedWorker) HandlesEvent added in v0.13.0

func (*UnimplementedWorker) HandlesEvent(trigger *triggers.Event) bool

func (*UnimplementedWorker) HandlesHttpRequest added in v0.13.0

func (*UnimplementedWorker) HandlesHttpRequest(trigger *triggers.HttpRequest) bool

type Worker

type Worker interface {
	Delegate
	Adapter
}

func InstrumentedWorkerFn added in v0.21.0

func InstrumentedWorkerFn(w Worker) Worker

type WorkerPool

type WorkerPool interface {
	// WaitForMinimumWorkers - A blocking method
	WaitForMinimumWorkers(timeout int) error
	GetWorkerCount() int
	GetWorker(*GetWorkerOptions) (Worker, error)
	GetWorkers(*GetWorkerOptions) []Worker
	AddWorker(Worker) error
	RemoveWorker(Worker) error
	Monitor() error
}

func NewProcessPool

func NewProcessPool(opts *ProcessPoolOptions) WorkerPool

NewProcessPool - Creates a new process pool

type WrappedWorkerFn added in v0.21.0

type WrappedWorkerFn func(Worker) Worker

Jump to

Keyboard shortcuts

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