server

package
v0.0.0-...-547fd59 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	WorkerMax      = os.Getenv("MAX_WORKERS")
	WorkerQueueMax = os.Getenv("MAX_WORKER_QUEUE")

	WorkerMaxDefault      = 10
	WorkerQueueMaxDefault = 10
)
View Source
var (
	JobQueueMax = os.Getenv("MAX_JOB_QUEUE")

	JobQueueMaxDefault = 10
)

Functions

func EnqueueJob

func EnqueueJob(job Job)

func GetJobQueue

func GetJobQueue() chan Job

func NewJobQueue

func NewJobQueue()

func Run

func Run(ctx context.Context, addr string, c Controller) error

Run creates the HTTP handler based on an implementation of a controller.Controller interface, and begins to listen on the specified address.

func RunTLS

func RunTLS(ctx context.Context, addr string, cert string, key string, c Controller) error

RunTLS creates the HTTPS handler based on an implementation of a controller.Controller interface, and begins to listen on the specified address.

Types

type Controller

type Controller interface {
	GetCatalog() (*brokerapi.Catalog, error)

	GetServiceInstanceStatus(instanceId, serviceID, PlanID string, operation string) (string, error)
	CreateServiceInstance(instanceId, serviceID, PlanID string, Parameter map[string]interface{}) error
	DeleteServiceInstance(instanceId, serviceID, PlanID string, Parameter map[string]string) error

	GetServiceBindingStatus(instanceId, serviceID, planID, bindingId string, operation string) (string, error)
	CreateServiceBinding(instanceId, serviceID, planID, bindingId string, Parameter map[string]interface{}) (brokerapi.Credential, error)
	DeleteServiceBinding(instanceId, serviceID, planID, bindingId string, Parameter map[string]string) error
}

Controller defines the APIs that the base function of Alibaba Cloud service broker is expected to support. Implementation should be concurrency-safe

type Dispatcher

type Dispatcher struct {
	// A pool of each worker's job channel that are registered with the dispatcher
	WorkerPool chan chan Job
}

Dispatcher dispatch incoming jobs to idle worker's job channel

func NewDispatcher

func NewDispatcher() *Dispatcher

func (*Dispatcher) Run

func (d *Dispatcher) Run()

type Job

type Job struct {
	Payload JobPayload
}

type JobPayload

type JobPayload interface {
	Deal() error
}

type Worker

type Worker struct {
	WorkerPool chan chan Job
	JobChannel chan Job
	// contains filtered or unexported fields
}

func NewWorker

func NewWorker(workerPool chan chan Job, maxQueue int) *Worker

func (*Worker) Start

func (w *Worker) Start()

Jump to

Keyboard shortcuts

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