hub

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPayload

func NewPayload(data interface{}, batch bool) *payload

Types

type Hub

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

Hub acts as the messaging hub between components -- that is, it controls how the communication that goes through channels are handled.

func New

func New(bufsiz int) *Hub

NewHub creates a new Hub struct

func (*Hub) Batch

func (h *Hub) Batch(ctx context.Context, f func(ctx context.Context), shouldLock bool)

Batch allows you to synchronously send messages during the scope of f() being executed.

func (*Hub) DrawCh

func (h *Hub) DrawCh() chan Payload

DrawCh returns the channel to redraw the terminal display

func (*Hub) PagingCh

func (h *Hub) PagingCh() chan Payload

PagingCh returns the channel to page through the results

func (*Hub) QueryCh

func (h *Hub) QueryCh() chan Payload

QueryCh returns the underlying channel for queries

func (*Hub) SendDraw

func (h *Hub) SendDraw(ctx context.Context, options interface{})

SendDraw sends a request to redraw the terminal display

func (*Hub) SendDrawPrompt

func (h *Hub) SendDrawPrompt(ctx context.Context)

SendDrawPrompt sends a request to redraw the prompt only

func (*Hub) SendPaging

func (h *Hub) SendPaging(ctx context.Context, x interface{})

SendPaging sends a request to move the cursor around

func (*Hub) SendPurgeDisplayCache

func (h *Hub) SendPurgeDisplayCache(ctx context.Context)

func (*Hub) SendQuery

func (h *Hub) SendQuery(ctx context.Context, q string)

SendQuery sends the query string to be processed by the Filter

func (*Hub) SendStatusMsg

func (h *Hub) SendStatusMsg(ctx context.Context, q string)

SendStatusMsg sends a string to be displayed in the status message

func (*Hub) SendStatusMsgAndClear

func (h *Hub) SendStatusMsgAndClear(ctx context.Context, q string, clearDelay time.Duration)

SendStatusMsgAndClear sends a string to be displayed in the status message, as well as a delay until the message should be cleared

func (*Hub) StatusMsgCh

func (h *Hub) StatusMsgCh() chan Payload

StatusMsgCh returns the channel to update the status message

type Payload

type Payload interface {
	// Batch returns true if this payload is part of a batch operation.
	Batch() bool

	// Data allows you to retrieve the data that's embedded in the payload.
	Data() interface{}

	// Done is called when the payload has been processed. There are cases
	// where the payload processing is expected to be synchronized with the
	// caller, and this method signals the caller that it is safe to proceed
	// to whatever next action it was expecting
	Done()
}

Payload is a wrapper around the actual request value that needs to be passed. It contains an optional channel field which can be filled to force synchronous communication between the sender and receiver

type StatusMsg added in v1.1.0

type StatusMsg interface {
	Message() string
	Delay() time.Duration
}

Jump to

Keyboard shortcuts

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