All Projects → genkami → Kiara

genkami / Kiara

Licence: mit
Backend-agnostic, lightweight pub/sub library which makes it easy for Go applications to communicate with each other.

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Labels

Projects that are alternatives of or similar to Kiara

Broker
Zeek's Messaging Library
Stars: ✭ 53 (-58.91%)
Mutual labels:  pubsub
Facil.io
Your high performance web application C framework
Stars: ✭ 1,393 (+979.84%)
Mutual labels:  pubsub
Wampy
Websocket RPC and Pub/Sub for Python applications and microservices
Stars: ✭ 115 (-10.85%)
Mutual labels:  pubsub
Lile
Easily generate gRPC services in Go ⚡️
Stars: ✭ 1,271 (+885.27%)
Mutual labels:  pubsub
Nymph
Data objects for JavaScript and PHP.
Stars: ✭ 97 (-24.81%)
Mutual labels:  pubsub
Autobahn Java
WebSocket & WAMP in Java for Android and Java 8
Stars: ✭ 1,467 (+1037.21%)
Mutual labels:  pubsub
Engine And Editor
Streamr Core backend
Stars: ✭ 44 (-65.89%)
Mutual labels:  pubsub
Event Gateway
React to any event with serverless functions across clouds
Stars: ✭ 1,604 (+1143.41%)
Mutual labels:  pubsub
Pulsar Dotpulsar
The official .NET client library for Apache Pulsar
Stars: ✭ 101 (-21.71%)
Mutual labels:  pubsub
Dapr Demos
Collection of personal Dapr demos (bindings, state, pub/sub, service-to-service invocation)
Stars: ✭ 109 (-15.5%)
Mutual labels:  pubsub
Chat Engine
Object oriented event emitter based framework for building chat applications in Javascript.
Stars: ✭ 87 (-32.56%)
Mutual labels:  pubsub
Autobahn Js
WAMP in JavaScript for Browsers and NodeJS
Stars: ✭ 1,345 (+942.64%)
Mutual labels:  pubsub
Samples
Community driven repository for Dapr samples
Stars: ✭ 104 (-19.38%)
Mutual labels:  pubsub
Kubemq
KubeMQ is Enterprise-grade message broker native for Docker and Kubernetes
Stars: ✭ 58 (-55.04%)
Mutual labels:  pubsub
Frugal
Thrift improved
Stars: ✭ 113 (-12.4%)
Mutual labels:  pubsub
Beaver
💨 A real time messaging system to build a scalable in-app notifications, multiplayer games, chat apps in web and mobile apps.
Stars: ✭ 1,056 (+718.6%)
Mutual labels:  pubsub
Open62541
Open source implementation of OPC UA (OPC Unified Architecture) aka IEC 62541 licensed under Mozilla Public License v2.0
Stars: ✭ 1,643 (+1173.64%)
Mutual labels:  pubsub
Syndicate
syn·di·cate: a language for interactive programs
Stars: ✭ 128 (-0.78%)
Mutual labels:  pubsub
Jpost
Java and Android class communication library: New and improved Pub-Sub
Stars: ✭ 117 (-9.3%)
Mutual labels:  pubsub
Flare
Flare is a service that notify changes of HTTP endpoints
Stars: ✭ 110 (-14.73%)
Mutual labels:  pubsub

Kiara

ci status Go Reference

phoenix

Kiara is a Go equivalent of Phoenix PubSub that makes it easy for Go applications to communicate with each other.

Examples

demo chat application

Basic Usage (with Redis Backend)

package main

import (
	"context"
	"fmt"

	"github.com/genkami/kiara"
	adapter "github.com/genkami/kiara/adapter/redis"
	"github.com/go-redis/redis/v8"
)

type Message struct {
	From string
	Body string
}

func main() {
	var err error
	redisClient := redis.NewClient(&redis.Options{Addr: "localhost:6379"})
	pubsub := kiara.NewPubSub(adapter.NewAdapter(redisClient))
	defer pubsub.Close()

	channel := make(chan Message, 5)
	sub, err := pubsub.Subscribe("room:123", channel)
	if err != nil {
		panic(err)
	}
	defer sub.Unsubscribe()

	ctx := context.Background()
	msg := &Message{From: "birb", Body: "cock-a-doodle-doo"}
	err = pubsub.Publish(ctx, "room:123", msg)
	if err != nil {
		panic(err)
	}

	sent := <-channel
	fmt.Printf("%s: %s\n", sent.From, sent.Body)
}

Run Test

To run an entire test, you need to run Redis and NATS, and to tell their addresses to test cases by setting environment variables.

We have docker-compose.yml to set up these dependencies easily. To run tests with docker-compose, type these following commands:

$ docker-compose up -d
$ export KIARA_TEST_REDIS_ADDR=localhost:6379
$ export KIARA_TEST_NATS_URL=nats://localhost:4222
$ go test ./...

Codec

By default, messages are marshaled into gob format. You can specify which codec Kiara uses to marshal and unmarshal messages by passing WithCodec() to NewPubSub().

import "github.com/genkami/kiara/codec/msgpack"

pubsub := kiara.NewPubSub(
    adapter.NewAdapter(redisClient),
    kiara.WithCodec(msgpack.Codec),
)

Currently these codecs are officially available:

Custom Codec

You can implement your own codec by simply implementing Marshal and Unmarshal. For example, if you want to encode messages into WATSON, you have to implement WATSON codec like this:

import 	"github.com/genkami/watson"

type WatsonCodec struct{}

func (_ *WatsonCodec) Marshal(v interface{}) ([]byte, error) {
	return watson.Marshal(v)
}

func (_ *WatsonCodec) Unmarshal(src []byte, v interface{}) error {
	return watson.Unmarshal(src, v)
}

Backend-Agnostic

Kiara does not depend on specific message broker implementation. Currently these message brokers are officially supported:

You can change backend message brokers with little effort. Here are examples of connecting to Redis and NATS as a Kiara's backend.

Example(Redis):

import (
    "github.com/go-redis/redis/v8"
    adapter "github.com/genkami/kiara/adapter/redis"
)
redisClient := redis.NewClient(&redis.Options{Addr: "localhost:6379"})
pubsub := kiara.NewPubSub(adapter.NewAdapter(redisClient))

Example(NATS):

import (
    "github.com/nats-io/nats.go"
    adapter "github.com/genkami/kiara/adapter/nats"
)
conn, err := nats.Connect("nats://localhost:4222")
// error handling omitted
pubsub := kiara.NewPubSub(adapter.NewAdapter(conn))

License

Distributed under the MIT License. See LICENSE for more information.

Acknowledgements

This library is highly inspired by phoenixframework/phoenix_pubsub, nats-io/nats.go, and the majestic phoenix Takanashi Kiara.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].