OK

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: CC0-1.0, MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Btrue     = "true"
	BtrueLen  = len(Btrue)
	Bfalse    = "false"
	BfalseLen = len(Bfalse)
)

Variables

This section is empty.

Functions

func Message

func Message(reason Reason, prefix string) string

Message takes a string message that is to be sent in an `OK` or `CLOSED` command and prefixes it with "<prefix>: " if it doesn't already have an acceptable prefix.

Types

type Envelope

type Envelope struct {
	EventID eventid.EventID
	OK      bool
	Reason  string
}

Envelope is a relay message sent in response to an EventEnvelope to indicate acceptance (OK is true), rejection and provide a human readable Reason for clients to display to users, with the first word being a machine readable reason type, as listed in the RejectReason* constants above, followed by ": " and a human readable message.

func NewOKEnvelope

func NewOKEnvelope(eventID eventid.EventID, ok bool, reason string) (o *Envelope,
	e error)

func (*Envelope) Bytes

func (env *Envelope) Bytes() (s []byte)

func (*Envelope) Label

func (env *Envelope) Label() (l string)

func (*Envelope) MarshalJSON

func (env *Envelope) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoded form of the envelope.

func (*Envelope) String

func (env *Envelope) String() (s string)

func (*Envelope) ToArray

func (env *Envelope) ToArray() (a array.T)

func (*Envelope) Unmarshal

func (env *Envelope) Unmarshal(buf *text.Buffer) (e error)

Unmarshal the envelope.

type Reason

type Reason string
const (
	PoW         Reason = "pow"
	Duplicate   Reason = "duplicate"
	Blocked     Reason = "blocked"
	RateLimited Reason = "rate-limited"
	Invalid     Reason = "invalid"
	Error       Reason = "error"
)

Jump to

Keyboard shortcuts

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