go-longpoll alternatives and similar packages
Based on the "Messaging" category.
Alternatively, view go-longpoll alternatives based on common mentions on social networks and blogs.
-
Centrifugo
Scalable real-time messaging server in a language-agnostic way. Set up once and forever. -
machinery
Machinery is an asynchronous task queue/job queue based on distributed message passing. -
NATS Go Client
Golang client for NATS, the cloud native messaging system. -
Confluent Kafka Golang Client
Confluent's Apache Kafka Golang client -
Mercure
An open, easy, fast, reliable and battery-efficient solution for real-time communications -
APNs2
⚡ HTTP/2 Apple Push Notification Service (APNs) push provider for Go — Send push notifications to iOS, tvOS, Safari and OSX apps, using the APNs HTTP/2 protocol. -
Uniqush-Push
Uniqush is a free and open source software system which provides a unified push service for server side notification to apps on mobile devices. -
Chanify
Chanify is a safe and simple notification tools. This repository is command line tools for Chanify. -
amqp
An AMQP 0-9-1 Go client maintained by the RabbitMQ team. Originally by @streadway: `streadway/amqp` -
mangos
mangos is a pure Golang implementation of nanomsg's "Scalablilty Protocols" -
PingMe
PingMe is a CLI which provides the ability to send messages or alerts to multiple messaging platforms & email. -
emitter
Emits events in Go way, with wildcard, predicates, cancellation possibilities and many other good wins -
Bus
🔊Minimalist message bus implementation for internal communication with zero-allocation magic on Emit -
redisqueue
redisqueue provides a producer and consumer of a queue that uses Redis streams -
go-mq
Declare AMQP entities like queues, producers, and consumers in a declarative way. Can be used to work with RabbitMQ. -
drone-line
Sending line notifications using a binary, docker or Drone CI. -
nsq-event-bus
A tiny wrapper around NSQ topic and channel :rocket: -
go-events
:mega: Pure nodejs EventEmmiter for the Go Programming Language. -
RapidMQ
RapidMQ is a pure, extremely productive, lightweight and reliable library for managing of the local messages queue -
Ratus
Ratus is a RESTful asynchronous task queue server. It translated concepts of distributed task queues into a set of resources that conform to REST principles and provides a consistent HTTP API for various backends based on embedded or external storage engines. -
go-notify
Package notify provides an implementation of the Gnome DBus Notifications Specification. -
Commander
Build event-driven and event streaming applications with ease -
structured pubsub
Publish and subscribe functionality within a single process in Go. -
go-vitotrol
golang client library to Viessmann Vitotrol web service -
jazz
Abstraction layer for simple rabbitMQ connection, messaging and administration
Access the most powerful time series database as a service
Do you think we are missing an alternative of go-longpoll or a related project?
README
Parked: PubSub with long polling in Go
The package longpoll
provides an implementation of the
long-polling mechanism of the PubSub pattern. Although the primary purpose of the
library is to aid the development of web applications, the library provides no specific web
handlers and can be used in other distributed applications.
Long polling is a technique to notify client applications about updates on the server. It is often used in writing web application as a substitute for the push technique, however can be used in other distributed applications.
Clients initiate subscriptions to the server specifying topics they are interested in. Given a subscription Id a client makes a request for new data. The request is held open until data becomes available on the server (published to a matching topic). As soon as this happens the request is answered immediately. If no data arrives over a predefined time window (the long-polling interval) the request returns empty. A new connection is then established between the client and the server to receive further updates.
The following points are often listed as the benefits of long-polling over the push mechanism in web applications:
- does not require a persistent connection to the server
- works for slow clients as they receive information at the speed they can process, although maybe in large chunks which are accumulated at the server between requests
- friendly to proxies blocking streaming
Implementation details and examples
Subscriptions will timeout and get closed if no client request is received over a given timeout interval. Every request resets the timeout counter. The timeout interval is a property of the subscription itself and different subscriptions may have different timeout intervals.
The long-polling interval, within which the request is held, is specified per request. Web application wrappers might provide defaults.
The library supports concurrent long-polling requests on the same subscription Id, but no data will be duplicated across request responses. No specific distribution of data across responses is guaranteed: new requests signal the existing one to return immediately.
At the moment the library does not support persisting of published data before it is collected by subscribers. All the published data is stored in memory of the backend.
Long-polling with subscription management:
Handling of long-polling subscriptions, publishing and receiving data is done by the
longpoll.LongPoll
type:
ps := longpoll.New()
id1, _ := ps.Subscribe(time.Minute, "TopicA", "TopicB")
id2, _ := ps.Subscribe(time.Minute, "TopicB", "TopicC")
go func() {
for {
if datach, err := ps.Get(id1, 30*time.Second); err == nil {
fmt.Printf("%v received %v", id1, <-datach)
} else {
break
}
}
}()
go func() {
for {
if datach, err := ps.Get(id2, 20*time.Second); err == nil {
fmt.Printf("%v received %v", id2, <-datach)
} else {
break
}
}
}()
for {
// data published on TopicB will be received by id1 and id2, TopicC by id2 only
ps.Publish({"random": rand.Float64()}, "TopicB", "TopicC")
// sleep for up to 50s
time.Sleep(time.Duration(rand.Intn(5e10)))
}
Long-polling on a single subscription channel:
Handling of the single-channel long-polling pubsub is done by the longpoll.Sub
type:
ch := longpoll.MustNewChannel(time.Minute, func (id string) {
// action on exit
}, "TopicA", "TopicB")
go func() {
for {
if datach, err := ch.Get(20*time.Second); err == nil {
fmt.Printf("received %v", <-datach)
} else {
break
}
}
}()
for {
ch.Publish({"random": rand.Float64()}, "TopicB")
// above subscription will not receive this data
ch.Publish({"random": rand.Float64()}, "TopicC")
// sleep for up to 50s
time.Sleep(time.Duration(rand.Intn(5e10)))
}
License and copyright
Copyright (c) 2015-2017. Oleg Sklyar and teris.io. MIT license applies. All rights reserved.
*Note that all licence references and agreements mentioned in the go-longpoll README section above
are relevant to that project's source code only.