longpoll

package module
v0.0.0-...-935c464 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2018 License: MIT Imports: 12 Imported by: 0

README

Golang HTTP Longpoll Server

This library is heavily inspired by J Cuga's golongpoll project. I just needed to simplify some things.

Main Changes

  • No more categories - each category needs to have its own longpoll instance.
  • Last Value Cache - when creating a new longpoll manager, you can specify if it should just cache the last published value rather than maintain a history of published values.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoSubscribersError = errors.New("no subscribers")

Functions

func MillisecondEpoch

func MillisecondEpoch(now time.Time) int64

Types

type Event

type Event struct {
	Data json.RawMessage `json:"data"`
}

type Manager

type Manager struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewManager

func NewManager(lvc bool) *Manager

func (*Manager) Publish

func (this *Manager) Publish(data interface{}) error

func (*Manager) ServeHTTP

func (this *Manager) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Message

type Message struct {
	Error     string  `json:"error"`
	Timestamp int64   `json:"timestamp"`
	Events    []Event `json:"events"`
}

type Watcher

type Watcher struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewWatcher

func NewWatcher(s string, t *http.Transport, w time.Time) *Watcher

func (*Watcher) Watch

func (this *Watcher) Watch(ctx context.Context, path string, events chan Event) error

Jump to

Keyboard shortcuts

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