worker

package
v0.17.1-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2022 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGrpcListener added in v0.13.0

func NewGrpcListener(stream v1.FaasService_TriggerStreamServer) *grpcWorkerBase

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 FaasWorker

type FaasWorker struct {
	GrpcWorker
}

FaasWorker Worker representation for a Nitric FaaS function using gRPC

func NewFaasWorker

func NewFaasWorker(stream pb.FaasService_TriggerStreamServer) *FaasWorker

NewFaasWorker - Create a new FaaS worker

type GetWorkerOptions added in v0.13.0

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

type GrpcWorker added in v0.13.0

type GrpcWorker interface {
	Worker
	Listen(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(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(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 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 {
	GrpcWorker
	// contains filtered or unexported fields
}

RouteWorker - Worker representation for an http api route handler

func NewRouteWorker added in v0.13.0

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(trigger *triggers.Event) error

func (*RouteWorker) HandleHttpRequest added in v0.13.0

func (s *RouteWorker) HandleHttpRequest(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 {
	GrpcWorker
	// contains filtered or unexported fields
}

RouteWorker - Worker representation for an http api route handler

func NewScheduleWorker added in v0.13.0

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

func (*ScheduleWorker) HandleHttpRequest added in v0.13.0

func (s *ScheduleWorker) HandleHttpRequest(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 {
	GrpcWorker
	// contains filtered or unexported fields
}

RouteWorker - Worker representation for an http api route handler

func NewSubscriptionWorker added in v0.13.0

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

func (*SubscriptionWorker) HandleHttpRequest added in v0.13.0

func (s *SubscriptionWorker) HandleHttpRequest(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 {
	HandleEvent(trigger *triggers.Event) error
	HandleHttpRequest(trigger *triggers.HttpRequest) (*triggers.HttpResponse, error)
	HandlesHttpRequest(trigger *triggers.HttpRequest) bool
	HandlesEvent(trigger *triggers.Event) bool
}

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

Jump to

Keyboard shortcuts

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