types

package
v0.0.0-...-1cbd840 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentTypeProtobuf   = "application/vnd.google.protobuf"
	ContentTypeFlatbuffer = "application/x-flatbuffers"
	ContentTypeJSON       = "application/json"
)
View Source
const (
	// const attributes keys the queue service implement must provide.
	Backend                    = "meta.backend"
	Name                       = "meta.name"
	State                      = "meta.state"
	MaxPayloadBytes            = "meta.maxPayloadBytes"
	UserIdentifyHeader         = "meta.header.user"
	GroupIdentifyHeader        = "meta.header.group"
	PriorityHeader             = "meta.header.priority"
	StreamLength               = "stream.length"
	StreamApproximateMaxLength = "stream.approxMaxLength"
	StreamLastEntry            = "stream.lastEntry"
	StreamFirstEntry           = "stream.firstEntry"

	// not necessary attribute keys
	ConsumersTotal = "consumers.status.total"
)

const attributes keys the queue service implement must provide.

Variables

Functions

func Compare

func Compare(o1, o2 Offset) (int, error)

func NewLengthDelimitedFrameReader

func NewLengthDelimitedFrameReader(r io.ReadCloser) io.ReadCloser

NewLengthDelimitedFrameReader returns an io.Reader that will decode length-prefixed frames off of a stream.

The protocol is:

stream: message ...
message: prefix body
prefix: 4 byte uint32 in BigEndian order, denotes length of body
body: bytes (0..prefix)

If the buffer passed to Read is not long enough to contain an entire frame, io.ErrShortRead will be returned along with the number of bytes read.

func NewLengthDelimitedFrameWriter

func NewLengthDelimitedFrameWriter(w io.Writer) io.Writer

func WithUser

func WithUser(ctx context.Context, user User) context.Context

WithUser saves User into context.

Types

type Attributes

type Attributes map[string]string

type AttributesCodec

type AttributesCodec interface {
	MediaType() string

	AttributesEncoder

	AttributesDecoder
}

AttributesCodec helps to encode or decode Attributes from or to bytes.

func AttributesCodecFor

func AttributesCodecFor(contentType string) AttributesCodec

type AttributesDecoder

type AttributesDecoder interface {
	Decode([]byte, *Attributes) error
}

type AttributesEncoder

type AttributesEncoder interface {
	Encode(Attributes Attributes, w io.Writer) error
}

type Code

type Code string
const (
	// Shutdown indicates the consumer will exit soon.
	Shutdown Code = "Shutdown"
)

some well-known Codes.

func (Code) String

func (c Code) String() string

func (Code) Verify

func (c Code) Verify() error

type DataFrame

type DataFrame struct {
	Data []byte

	Index Index

	Tags Tags

	Message string
}

func (*DataFrame) Empty

func (f *DataFrame) Empty() bool

type DataFrameCodec

type DataFrameCodec interface {
	MediaType() string

	DataFrameEncoder

	DataFrameDecoder
}

DataFrameCodec helps to encode or decode a DataFrame from or to bytes.

func DataFrameCodecFor

func DataFrameCodecFor(contentType string) DataFrameCodec

type DataFrameDecoder

type DataFrameDecoder interface {
	// Decode decodes DataFrame from bytes.
	Decode([]byte, *DataFrame) error

	// DecodeList attempts to decode DataFrameList from bytes.
	DecodeList([]byte) ([]DataFrame, error)
}

type DataFrameEncoder

type DataFrameEncoder interface {
	// Encode encodes DataFrame into bytes.
	Encode(frame DataFrame, w io.Writer) error

	// EncodeList attempts to encode batch of DataFrame into bytes.
	EncodeList(list []DataFrame, w io.Writer) error
}

type DataFrameReader

type DataFrameReader interface {
	// FrameChan return a DataFrame channel.
	FrameChan() <-chan DataFrame
}

type Index

type Index uint64

func FromUint64

func FromUint64(i uint64) Index

func FromUint64Slice

func FromUint64Slice(ii []uint64) []Index

func LargestIndex

func LargestIndex(dfs []DataFrame) Index

func (Index) Uint64

func (i Index) Uint64() uint64

type Offset

type Offset string
const (
	OffsetEOS Offset = "eos"
)

func (Offset) IsInf

func (o Offset) IsInf() bool

func (Offset) Uint64

func (o Offset) Uint64() (uint64, bool)

type Priority

type Priority int64

func (Priority) String

func (p Priority) String() string

type StreamStatus

type StreamStatus string
const (
	StreamOk     StreamStatus = "OK"
	StreamCancel StreamStatus = "Cancel"
	StreamEnd    StreamStatus = "End"
)

type Tags

type Tags map[string]string

func (Tags) Contains

func (t Tags) Contains(t1 Tags) bool

func (Tags) Diff

func (t Tags) Diff(t1 Tags) (add Tags, del Tags, update Tags)

func (Tags) Empty

func (t Tags) Empty() bool

func (Tags) Equals

func (t Tags) Equals(t1 Tags) bool

func (Tags) Get

func (t Tags) Get(key string) string

func (Tags) Has

func (t Tags) Has(key string) bool

func (Tags) Set

func (t Tags) Set(key string, value string)

func (Tags) String

func (t Tags) String() string

func (Tags) ToJSON

func (t Tags) ToJSON() string

func (Tags) Validate

func (t Tags) Validate() error

type User

type User interface {
	// Uid represents the user id.
	Uid() string

	// Gid represents the group id of user.
	Gid() string

	// Token represents the access token of the queue service.
	Token() string
}

User authenticated information.

func UserFromContext

func UserFromContext(ctx context.Context) (User, bool)

UserFromContext loads User from context.

type UserAware

type UserAware interface {
	// User returns the user info.
	User() User
}

type UserWithToken

type UserWithToken interface {
	// Token to access the backend service.
	Token() string
}

type Watcher

type Watcher interface {
	// Watcher is a kind of DataFrameReader.
	DataFrameReader
	// Close stops Watcher and closes the FrameChan.
	Close()
}

Watcher is the entity following the stream.

type WorkerStatus

type WorkerStatus string
const (
	WorkerRunning WorkerStatus = "Running"
	WorkerStopped WorkerStatus = "Stopped"
	WorkerError   WorkerStatus = "Error"
	WorkerUnknown WorkerStatus = "Unknown"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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