worker

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var METHOD_TYPE = []byte("POST")

Functions

This section is empty.

Types

type FaasHttpWorker

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

A Nitric HTTP worker

func NewFaasHttpWorker

func NewFaasHttpWorker(address string) (*FaasHttpWorker, error)

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

func (*FaasHttpWorker) HandleEvent

func (h *FaasHttpWorker) HandleEvent(trigger *triggers.Event) error

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

func (*FaasHttpWorker) HandleHttpRequest

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

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

type FaasWorker

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

FaasWorker Worker representation for a Nitric FaaS function using gRPC

func NewFaasWorker

func NewFaasWorker(stream pb.FaasService_TriggerStreamServer) *FaasWorker

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

func (*FaasWorker) HandleEvent

func (s *FaasWorker) HandleEvent(trigger *triggers.Event) error

func (*FaasWorker) HandleHttpRequest

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

func (*FaasWorker) Listen

func (s *FaasWorker) Listen(errchan chan error)

listen

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.

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 added in v0.3.0

func (p *ProcessPool) GetMaxWorkers() int

GetMaxWorkers - return the maximum number of workers for this pool

func (*ProcessPool) GetMinWorkers added in v0.3.0

func (p *ProcessPool) GetMinWorkers() int

GetMinWorkers - return the minimum number of workers for this pool

func (*ProcessPool) GetWorker

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

GetWorker - Retrieves a worker from this pool

func (*ProcessPool) GetWorkerCount added in v0.3.0

func (p *ProcessPool) GetWorkerCount() int

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 added in v0.3.0

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 UnimplementedWorker

type UnimplementedWorker struct{}

func (*UnimplementedWorker) HandleEvent

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

func (*UnimplementedWorker) HandleHttpRequest

func (*UnimplementedWorker) HandleHttpRequest(trigger *triggers.HttpRequest) *http.Response

type Worker

type Worker interface {
	HandleEvent(trigger *triggers.Event) error
	HandleHttpRequest(trigger *triggers.HttpRequest) (*triggers.HttpResponse, error)
}

type WorkerPool

type WorkerPool interface {
	// WaitForMinimumWorkers - A blocking method
	WaitForMinimumWorkers(timeout int) error
	GetWorkerCount() int
	GetWorker() (Worker, error)
	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