web

package
v0.0.0-...-32bfc87 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: ISC Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSsh = fmt.Errorf("ssh error")

Functions

func Run

func Run(opt *Options)

how do we get flags from cobra command? compose?

Types

type Client

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

wrapper for websocket, should we make generic?

func (*Client) Close

func (c *Client) Close() error

func (*Client) Notify

func (c *Client) Notify(method string, params []byte, data []byte)

Notify implements Peer

func (*Client) Reply

func (c *Client) Reply(tag int64, result any, more []byte, err error)

func (*Client) Rpc

func (c *Client) Rpc(method string, params []byte, data []byte, tag int64)

Rpc implements Peer

type Config

type Config struct {
	Websocket string `json:"websocket,omitempty"`
	Drop      string `json:"drop,omitempty"`
}

type Configure

type Configure = func(data []byte) error

type NewWebClient

type NewWebClient = func(monitor Server, peer Peer) (Peer, error)

type Options

type Options struct {
	Home      string
	New       NewWebClient
	Configure Configure
	Fs        embed.FS
	Port      int
}

type Peer

type Peer interface {
	// primary need is for a way to read/write rpc's
	// json, cbor, arrow
	// {json rpc}\0binary
	// if first character is 0 then begin with cbor
	//io.Closer
	Rpc(method string, params []byte, data []byte, tag int64)
	Reply(tag int64, result any, more []byte, err error)
}

type Rpc

type Rpc struct {
	Method string          `json:"method,omitempty"`
	Id     int64           `json:"id,omitempty"`
	Params json.RawMessage `json:"params,omitempty"`
}

type RpcReply

type RpcReply struct {
	Id     int64           `json:"id,omitempty"`
	Result json.RawMessage `json:"result,omitempty"`
	Error  string          `json:"error,omitempty"`
}

type SecretCookie

type SecretCookie = string

type Server

type Server interface {
	Subscribe(topic string, browser Peer)
	Drop(topic string, browser Peer)
	Publish(topic string, data []byte, more []byte)
}

can configuration be a standard topic then? do we publish to it to set it? channels can have different behaviors for newcomers: get summary, get all, get new. Most common would be get summary. maybe each topic should be a file in a directory (separate? what if we are running from readonly? readonly starter config?) there are also more complex behaviors like update by character then commit.

type SessionId

type SessionId = string

type WebChannel

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

more generally this may be a pub sub channel with a default of all

Jump to

Keyboard shortcuts

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