go-res alternatives and similar packages
Based on the "Messaging" category.
Alternatively, view go-res alternatives based on common mentions on social networks and blogs.
-
sarama
DISCONTINUED. Sarama is a Go library for Apache Kafka. [Moved to: https://github.com/IBM/sarama] -
Centrifugo
Scalable real-time messaging server in a language-agnostic way. Self-hosted alternative to Pubnub, Pusher, Ably. Set up once and forever. -
Benthos
DISCONTINUED. Fancy stream processing made operationally mundane [Moved to: https://github.com/redpanda-data/connect] -
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. -
amqp
An AMQP 0-9-1 Go client maintained by the RabbitMQ team. Originally by @streadway: `streadway/amqp` -
Chanify
Chanify is a safe and simple notification tools. This repository is command line tools for Chanify. -
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 -
go-mq
Declare AMQP entities like queues, producers, and consumers in a declarative way. Can be used to work with RabbitMQ. -
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. -
RapidMQ
RapidMQ is a pure, extremely productive, lightweight and reliable library for managing of the local messages queue
InfluxDB - Purpose built for real-time analytics at any scale.
Do you think we are missing an alternative of go-res or a related project?
README
RES Service for GoSynchronize Your Clients
Go package used to create REST, real time, and RPC APIs, where all your reactive web clients are synchronized seamlessly through Resgate.
Visit Resgate.io for more information.
Installation
go get github.com/jirenius/go-res
As easy as
package main
import res "github.com/jirenius/go-res"
func main() {
s := res.NewService("example")
s.Handle("model",
res.Access(res.AccessGranted),
res.GetModel(func(r res.ModelRequest) {
r.Model(struct {
Message string `json:"message"`
}{"Hello, World!"})
}),
)
s.ListenAndServe("nats://localhost:4222")
}
Prerequisite
Install NATS Server and Resgate. Can be done with 3 docker commands:
docker network create res docker run -d --name nats -p 4222:4222 --net res nats docker run --name resgate -p 8080:8080 --net res resgateio/resgate --nats nats://nats:4222
Examples
Example | Description |
---|---|
[Hello World](examples/01-hello-world/) | Smallest of services serving a static message. |
[Edit Text](examples/02-edit-text/) | Single text field that is updated in real time. |
[Book Collection](examples/03-book-collection/) | List of book titles & authors that can be edited by many. |
[Book Collection Store](examples/04-book-collection-store/) | Book Collection example persisting changes using BadgerBD store. |
[Search Query](examples/05-search-query/) | Make live queries against a large customer database. |
Note
Above examples are complete with both service and client.
Usage
Create a new service
s := res.NewService("myservice")
Add handlers for a model resource
mymodel := map[string]interface{}{"name": "foo", "value": 42}
s.Handle("mymodel",
res.Access(res.AccessGranted),
res.GetModel(func(r res.ModelRequest) {
r.Model(mymodel)
}),
)
Add handlers for a collection resource
mycollection := []string{"first", "second", "third"}
s.Handle("mycollection",
res.Access(res.AccessGranted),
res.GetCollection(func(r res.CollectionRequest) {
r.Collection(mycollection)
}),
)
Add handlers for parameterized resources
s.Handle("article.$id",
res.Access(res.AccessGranted),
res.GetModel(func(r res.ModelRequest) {
article := getArticle(r.PathParam("id"))
if article == nil {
r.NotFound()
} else {
r.Model(article)
}
}),
)
Add handlers for method calls
s.Handle("math",
res.Access(res.AccessGranted),
res.Call("double", func(r res.CallRequest) {
var p struct {
Value int `json:"value"`
}
r.ParseParams(&p)
r.OK(p.Value * 2)
}),
)
Send change event on model update
A change event will update the model on all subscribing clients.
s.With("myservice.mymodel", func(r res.Resource) {
mymodel["name"] = "bar"
r.ChangeEvent(map[string]interface{}{"name": "bar"})
})
Send add event on collection update:
An add event will update the collection on all subscribing clients.
s.With("myservice.mycollection", func(r res.Resource) {
mycollection = append(mycollection, "fourth")
r.AddEvent("fourth", len(mycollection)-1)
})
Add handlers for authentication
s.Handle("myauth",
res.Auth("login", func(r res.AuthRequest) {
var p struct {
Password string `json:"password"`
}
r.ParseParams(&p)
if p.Password != "mysecret" {
r.InvalidParams("Wrong password")
} else {
r.TokenEvent(map[string]string{"user": "admin"})
r.OK(nil)
}
}),
)
Add handlers for access control
s.Handle("mymodel",
res.Access(func(r res.AccessRequest) {
var t struct {
User string `json:"user"`
}
r.ParseToken(&t)
if t.User == "admin" {
r.AccessGranted()
} else {
r.AccessDenied()
}
}),
res.GetModel(func(r res.ModelRequest) {
r.Model(mymodel)
}),
)
Using routes
s.Route("v2", func(m *res.Mux) {
m.Handle("mymodel",
/* ... */
)
})
Start service
s.ListenAndServe("nats://localhost:4222")
Testing
The [restest](restest/) subpackage is used for testing services and validate responses.
Inter-service communication
The [resprot](resprot/) subpackage provides low level structs and methods for communicating with other services over NATS server.
Storage
The [store](store/) subpackage contains handlers and interfaces for working with database storage.
Name | Description | Documentation |
---|---|---|
[mockstore](store/mockstore/) | Mock store implementation for testing | |
[badgerstore](store/badgerstore/) | BadgerDB store implementation |
Credits
Inspiration on the go-res API has been taken from github.com/go-chi/chi, a great package when writing ordinary HTTP services, and will continue to do so when it is time to implement Middleware, sub-handlers, and mounting.
Contributing
The go-res package is still under development, but the API is mostly settled. Any feedback on the package API or its implementation is highly appreciated!
Once the API is fully settled, the package will be moved to the resgateio GitHub organization.
If you find any issues, feel free to report them as an issue.
*Note that all licence references and agreements mentioned in the go-res README section above
are relevant to that project's source code only.