delivery

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MSG_FLAG_CONNECTED        byte = 0
	MSG_FLAG_CONNECTED_ACK    byte = 1
	MSG_FLAG_ORDER            byte = 2
	MSG_FLAG_ORDER_ACK        byte = 3
	MSG_FLAG_ORDER_CANCEL     byte = 4
	MSG_FLAG_ORDER_RESULT     byte = 5
	MSG_FLAG_STATUS_SUBMIT    byte = 6
	MSG_FLAG_STATUS_BOARDCASE byte = 7
	MSG_FLAG_STATUS_PING      byte = 8
	MSG_FLAG_STATUS_INHERIT   byte = 9
)

Variables

View Source
var (
	DefaultTokenHashSalt = "ca205de6a03db4bf5376facdb172cb79"
	DefaultTokenHash     = tokenHash
)
View Source
var (
	ErrOffline         = errors.New("offline")
	ErrInvalidResponse = errors.New("invalid response")
	ErrOrderAckTimeout = errors.New("order ack timeout")
	ErrOrderTimeout    = errors.New("order timeout")
	ErrMenuNotServing  = errors.New("menu not serving")
)
View Source
var (
	DefaultListenAddr                 = "0.0.0.0"
	DefaultPubPort                    = 19527
	DefaultRepPort                    = 29527
	DefaultOrderHandleConcurrentLimit = 500
	DefaultReqSocketMax               = int32(100)
	DefaultOrderTimeout               = time.Second * 10
	DefaultOrderAckTimeout            = time.Second * 3
	DefaultStatusBroadcastInterval    = time.Second * 1
	LogErr                            = func(str string, err error, arg ...interface{}) {
		fmt.Println(str, err, arg)
	}
	LogInfo = func(args ...interface{}) {
		fmt.Println(args...)
	}
	LogDebug = func(args ...interface{}) {

	}
)
View Source
var (
	ErrRunInLocal = errors.New("run in local")
)
View Source
var (
	NewLoadBalancer = newLoadBalancer
)

Functions

This section is empty.

Types

type Deliverable

type Deliverable struct {
	Output  []byte
	Error   error
	OrderId uint64
}

type IHandler

type IHandler interface {
	// contains filtered or unexported methods
}

type ILoadBalancer

type ILoadBalancer interface {
	GetNodeId(skipNodeId ...uint32) uint32
	UpdateHandlers(handlers []IHandler)
}

type ILogistic

type ILogistic interface {
	Init() error
	SetOrderHandlerPerMenu([]func(context.Context, *Order))
	SwitchLeader(url string, port uint16)
	// Shutdown is for shutting down the logistic server keep every call in local
	Shutdown()
	IsLeader() bool
	// Order is for sending orders to cluster
	Order(menuId, dishId uint16, skipNodeIds ...uint32) (func(ctx context.Context, input []byte) ([]byte, error), error)
}

ILogistic is an interface of managing scaling of kitchen.

func NewServer

func NewServer(localHostUrl string, localRepPort uint16, mainHostUrl string, hostRepPort uint16) ILogistic

type Order

type Order struct {
	Response func([]byte, error) error
	Ack      func()
	Ctx      context.Context
	deliveryProto.Order
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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