client

package
v0.0.0-...-927f8ed Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2022 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Band

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

func (*Band) AskForHTTPBody

func (band *Band) AskForHTTPBody(maxSize int) (nn int, err error)

AskForHTTPBody requests the http body data from the queen. The queen will * return at maximum the amount of data specified with maxSize.

func (*Band) Close

func (band *Band) Close()

Close closes the connection and marks the band as closed so that it can be * removed from the list later.

func (*Band) ReadHTTPBody

func (band *Band) ReadHTTPBody() (getNext bool, data []byte, err error)

ReadHTTPBody reads a chunk of the request body. This function returns true * for getNext if the chunk was successfully read, and false if it encountered * an error or the request ended.

func (*Band) ReadHTTPBodyFull

func (band *Band) ReadHTTPBodyFull() (body []byte, err error)

ReadHTTPBodyFull reads all chunks of the request body, and returns the data * read as []byte.

func (*Band) ReadParseFrame

func (band *Band) ReadParseFrame() (
	kind protocol.FrameKind,
	data []byte,
	err error,
)

ReadParseFrame reads a single frame and parses it, separating the kind and * the data.

func (*Band) WriteHTTPBody

func (band *Band) WriteHTTPBody(data []byte) (nn int, err error)

WriteHTTPBody writes a chunk of the response body.

func (*Band) WriteHTTPHead

func (band *Band) WriteHTTPHead(
	code int,
	headers map[string][]string,
) (
	nn int,
	err error,
)

WriteHTTPHead writes HTTP header information. It should only be called once * when serving an HTTP response.

func (*Band) WriteMarshalFrame

func (band *Band) WriteMarshalFrame(frame protocol.Frame) (nn int, err error)

WriteMarshalFrame marshals and writes a Frame.

type Leash

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

Leash represents a connection to the server. Through it, the cell and the * server can communicate. Leashes are associated with a number of bands, which * are automatically created and destroyed as needed.

func NewLeash

func NewLeash() (leash *Leash)

NewLeash creates a new leash object. It does not connect the leash to a * server, this needs to be done via the Ensure() or Dial() function.

func (*Leash) Close

func (leash *Leash) Close()

Close closes the leash, and all bands in it. If the connection is ensured, * this will just re-connect afterwards. To stop this from happening, call the * Stop() method instead.

func (*Leash) Dial

func (leash *Leash) Dial(
	address string,
	key string,
	rootCertPath string,
) (
	err error,
)

Dial connects the leash to a server. This function is only useful in some * cases, Ensure is usually a better option.

func (*Leash) Ensure

func (leash *Leash) Ensure(
	address string,
	mount Mount,
	key string,
	rootCertPath string,
)

This is generally the function you will call to make a connection to a * server, except in some specific use cases. It automatically reconnects the * leash whenever the server goes offline and then back online again. This * function should generally be run in main() or in a separate goroutine. It * does not return.

func (*Leash) Listen

func (leash *Leash) Listen() (err error)

Listen listens for data sent over the leash.

func (*Leash) Mount

func (leash *Leash) Mount(host string, path string) (err error)

Mount tells the leash to mount on a particular pattern. This function is * thread safe.

func (*Leash) NewBand

func (leash *Leash) NewBand() (err error)

NewBand Creates a new band specifically for this leash, and adds it to the * list of bands.

func (*Leash) OnHTTP

func (leash *Leash) OnHTTP(
	callback func(band *Band, head *protocol.FrameHTTPReqHead),
)

OnHTTP specifies the http request handler function for the leash.

func (*Leash) Stop

func (leash *Leash) Stop()

Stop closes the leash, and all bands in it, preventing the leash from * reconnecting if it is ensured.

func (*Leash) Unmount

func (leash *Leash) Unmount(host string, path string) (err error)

Unmount tells the leash to unmount off of a particular pattern. This function * is thread safe.

type Mount

type Mount struct {
	Host string
	Path string
}

Mount represents a mount pattern. It has a Host and a Path field.

type Req

type Req interface {
	Kind() ReqKind
}

type ReqKind

type ReqKind int
const (
	ReqKindMount ReqKind = iota
	ReqKindUnmount
)

type ReqMount

type ReqMount struct {
	Host string
	Path string
	// contains filtered or unexported fields
}

func (*ReqMount) Kind

func (req *ReqMount) Kind() ReqKind

type ReqUnmount

type ReqUnmount struct {
	Host string
	Path string
	// contains filtered or unexported fields
}

func (*ReqUnmount) Kind

func (req *ReqUnmount) Kind() ReqKind

Jump to

Keyboard shortcuts

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