apiws

package
v0.0.0-...-72e33f6 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrVisitorEmpty = errors.New("visitor empty")

Functions

func Check

func Check(visitor Visitor, sig Signal)

func Flush

func Flush(ctx context.Context, vistor Visitor, writeC chan<- []byte) error

func Logger

func Logger(conn *websocket.Conn) zerolog.Logger

func Reader

func Reader(ctx context.Context, conn *websocket.Conn, log zerolog.Logger) <-chan []byte

func Upgrade

func Upgrade(w http.ResponseWriter, r *http.Request) (*websocket.Conn, error)

func Writer

func Writer(ctx context.Context, conn *websocket.Conn, log zerolog.Logger, sig Signal) <-chan chan []byte

Types

type BufferVisitor

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

func NewBufferVisitor

func NewBufferVisitor(count int) *BufferVisitor

func (*BufferVisitor) HasMore

func (v *BufferVisitor) HasMore() bool

func (*BufferVisitor) Push

func (v *BufferVisitor) Push(data []byte) bool

func (*BufferVisitor) Visit

func (v *BufferVisitor) Visit(ctx context.Context) ([]byte, error)

type OnceVisitor

type OnceVisitor struct {
	Done bool
	// contains filtered or unexported fields
}

func NewOnceVisitor

func NewOnceVisitor() *OnceVisitor

func (*OnceVisitor) HasMore

func (v *OnceVisitor) HasMore() bool

func (*OnceVisitor) Set

func (v *OnceVisitor) Set(data []byte)

func (*OnceVisitor) Visit

func (v *OnceVisitor) Visit(ctx context.Context) ([]byte, error)

type Signal

type Signal struct {
	C chan struct{}
}

func NewSignal

func NewSignal() Signal

func (Signal) Queue

func (s Signal) Queue()

type Visitor

type Visitor interface {
	Visit(ctx context.Context) ([]byte, error)
	HasMore() bool
}

type Vistors

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

func NewVisitors

func NewVisitors(visitors ...Visitor) Vistors

func (Vistors) HasMore

func (c Vistors) HasMore() bool

func (Vistors) Visit

func (c Vistors) Visit(ctx context.Context) ([]byte, error)

Jump to

Keyboard shortcuts

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