stream

package
v0.0.0-...-931a7b5 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StreamUpgrader = websocket.Upgrader{

	CheckOrigin: func(r *http.Request) bool {
		return r.Header.Get("Upgrade") == "websocket"
	},
	Subprotocols: []string{"bearer"},
}

Functions

This section is empty.

Types

type BroadcastOpt

type BroadcastOpt struct {
	Get      GetFn
	Callback func()
}

type Cache

type Cache struct {
	Version int64
	Data    []byte
}

Cache holds version and data

type Conn

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

Conn extends the websocket connection with a mutex https://godoc.org/github.com/gorilla/websocket#hdr-Concurrency

type EncodeFn

type EncodeFn func(data []byte) string

type GetFn

type GetFn func(key string) ([]byte, error)

type Pool

type Pool struct {
	Key string
	// contains filtered or unexported fields
}

Pool of key filtered connections

type Stream

type Stream struct {
	OnSubscribe   Subscribe
	OnUnsubscribe Unsubscribe
	ForcePatch    bool
	NoPatch       bool

	Console *coat.Console
	// contains filtered or unexported fields
}

Stream a group of pools

func (*Stream) Broadcast

func (sm *Stream) Broadcast(path string, opt BroadcastOpt)

Broadcast will look for pools that match a path and broadcast updates

func (*Stream) BroadcastClock

func (sm *Stream) BroadcastClock(data string)

BroadcastClock sends time to all the subscribers

func (*Stream) Close

func (sm *Stream) Close(key string, client *Conn)

Close client connection

func (*Stream) GetCacheVersion

func (sm *Stream) GetCacheVersion(key string) (int64, error)

GetCache by key

func (*Stream) InitClock

func (sm *Stream) InitClock()

func (*Stream) New

func (sm *Stream) New(key string, w http.ResponseWriter, r *http.Request) (*Conn, error)

New stream on a key

func (*Stream) Patch

func (sm *Stream) Patch(poolIndex int, data []byte) ([]byte, bool, int64)

Patch will return either the snapshot or the patch

patch, false (patch)

snapshot, true (snapshot)

func (*Stream) Read

func (sm *Stream) Read(key string, client *Conn)

Read will keep alive the ws connection

func (*Stream) Refresh

func (sm *Stream) Refresh(path string, getDataFn GetFn) Cache

func (*Stream) Write

func (sm *Stream) Write(client *Conn, data string, snapshot bool, version int64)

Write will write data to a ws connection

func (*Stream) WriteClock

func (sm *Stream) WriteClock(client *Conn, data string)

WriteClock sends time to a subscriber

type Subscribe

type Subscribe func(key string) error

Subscribe : monitoring or filtering of subscriptions

type Unsubscribe

type Unsubscribe func(key string)

Unsubscribe : function callback on subscription closing

Jump to

Keyboard shortcuts

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