pipe

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: MIT Imports: 3 Imported by: 0

README

shunt

  • 用于多路串行化处理,基本原理是启动一系列go routine,在任务分发时通过计算slot, 将不同的请求分发到不同slot对应的go routine上执行。

Documentation

Index

Constants

View Source
const (
	//DefaultSlotSize slot size
	//素数
	DefaultSlotSize = 509
	//DefaultQSize default pipe size, total current request can be pipe is 509*1024*8 = 4169728
	DefaultQSize = 1024 * 8
)

Variables

View Source
var (
	//ErrNoHandler -- no message handler
	ErrNoHandler = status.Error(codes.Unimplemented, "no.req.handler")
	//ErrQueueFull -- msg queue is full
	ErrQueueFull = status.Error(codes.ResourceExhausted, "req.queue.full")
	//ErrQueueClosed -- msg queue closed
	ErrQueueClosed = status.Error(codes.Unavailable, "req.queue.closed")
	//ErrInvalidParam -- invalid msg param
	ErrInvalidParam = status.Error(codes.InvalidArgument, "invalid.req.param")
	//ErrInvalidRsp -- invalid result
	ErrInvalidRsp = status.Error(codes.Internal, "invalid.rsp.msg")
)

Functions

func ConvertQueueErr added in v0.1.0

func ConvertQueueErr(err error) error

ConvertQueueErr convert msg queue error

func GetOption added in v0.1.0

func GetOption(opts ...Option) (slotSize int, qSize int)

GetOption : return slot size and q size

func NormalizeSlotIndex added in v0.1.0

func NormalizeSlotIndex(index int, slotSize int) int

NormalizeSlotIndex slot index

Types

type Option added in v0.1.0

type Option func(o *_Option)

Option shunt option function

func WithQSize added in v0.1.0

func WithQSize(qSize int) Option

WithQSize setup queue size in each slot

func WithSlotSize

func WithSlotSize(slotSize int) Option

WithSlotSize setup slot size

Directories

Path Synopsis
q

Jump to

Keyboard shortcuts

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