okenvelope

package
v1.1.22 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 10 Imported by: 1

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 Reason

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

type T

type T struct {
	ID     eventid.T
	OK     bool
	Reason string
}

T 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.T, ok bool, reason string) (o *T,
	err error)

func (*T) Bytes

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

func (*T) Label

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

func (*T) MarshalJSON

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

MarshalJSON returns the JSON encoded form of the envelope.

func (*T) String

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

func (*T) ToArray

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

func (*T) Unmarshal

func (env *T) Unmarshal(buf *text.Buffer) (err error)

Unmarshal the envelope.

func (*T) UnmarshalJSON

func (env *T) UnmarshalJSON(bytes []byte) error

Jump to

Keyboard shortcuts

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