cells

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2022 License: AGPL-3.0 Imports: 17 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 NewBand

func NewBand(
	conn net.Conn,
	reader *fsock.Reader,
	writer *fsock.Writer,
) (
	band *Band,
)

func (*Band) Close

func (band *Band) Close()

Close marks the band as closed, and ensures that the underlying socket is * also closed.

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) TryLock

func (band *Band) TryLock() bool

TryLock attempts to lock the band, and returns whether it succeeded or not. * A mutex is not used because if this function were blocking, a request might * have to wait for a huge file download to complete before being given a band.

func (*Band) Unlock

func (band *Band) Unlock()

Unlock unlocks the band, opening it for new requests.

func (*Band) WriteMarshalFrame

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

WriteMarshalFrame marshals and writes a Frame.

type Cell

type Cell struct {
	Reader *fsock.Reader
	Writer *fsock.Writer
	// contains filtered or unexported fields
}

Cell represents a connection to a cell server. It should only be created in * response to an incoming tls connection, using the Handle function.

func NewCell

func NewCell(
	leash net.Conn,
	reader *fsock.Reader,
	writer *fsock.Writer,
	uuidString string,
	onClean func(*Cell),
) (
	cell *Cell,
)

func (*Cell) Bind

func (cell *Cell) Bind(band *Band, key string) (err error)

Bind adds a band to the cell, and fulfils a pending request for more.

func (*Cell) HandleHTTP

func (cell *Cell) HandleHTTP(
	res http.ResponseWriter,
	req *http.Request,
)

HandleHTTP handles an http request directed at this cell. It selects a free * band, and then uses it to inform the cell of a new request and it pipes the * response back to the client.

func (*Cell) Key

func (cell *Cell) Key() string

Key returns the cell's key

func (*Cell) Listen

func (cell *Cell) Listen()
listen listens for incoming data on the socket, and uses it to fulfill

* requests.

func (*Cell) ListenSig

func (cell *Cell) ListenSig()

func (*Cell) MountFunc

func (cell *Cell) MountFunc(
	pattern string,
	callback func(http.ResponseWriter, *http.Request),
) (
	err error,
)

MountFunc is, for now, a wrapper around HolaMux.MountFunc().

func (*Cell) Provide

func (cell *Cell) Provide() (band *Band, err error)

Provide returns an unlocked band that is not currently being used. If it * can't find one, it puts in a request for one and waits until it is available. * The band must be manually re-locked after use! (except on error)

func (*Cell) Prune

func (cell *Cell) Prune() (pruned int)

Prune removes bands that haven't been used in a while, or have been marked as * closed.

func (*Cell) SendSig

func (cell *Cell) SendSig(sig Sig)

func (*Cell) Unmount

func (cell *Cell) Unmount() (err error)

Unmount is, for now, a wrapper around HolaMux.Unmount().

func (*Cell) Uuid

func (cell *Cell) Uuid() string

Uuid returns the cell's uuid

type Sig

type Sig int
const (
	SigCleaning Sig = iota
	SigNeedBand
)

Jump to

Keyboard shortcuts

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