All Projects → myself659 → chanbroker

myself659 / chanbroker

Licence: other
ChanBroker, a Broker for goroutine, is simliar to kafka

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to chanbroker

captcha
Go package captcha generation and verification of image, Refer from https://github.com/dchest/captcha. Use captcha pool generation
Stars: ✭ 29 (-52.46%)
Mutual labels:  channel, goroutine
mqtt-bm-latency
A MQTT benchmark tool to measure the broker's forwarding latency.
Stars: ✭ 28 (-54.1%)
Mutual labels:  broker
Investigo
🔎 Find usernames and download their data across social media.
Stars: ✭ 168 (+175.41%)
Mutual labels:  goroutine
MQTTnet
MQTTnet is a high performance .NET library for MQTT based communication. It provides a MQTT client and a MQTT server (broker). The implementation is based on the documentation from http://mqtt.org/.
Stars: ✭ 3,309 (+5324.59%)
Mutual labels:  broker
workerpool
A workerpool that can get expanded & shrink dynamically.
Stars: ✭ 55 (-9.84%)
Mutual labels:  goroutine
Hunch
Hunch provides functions like: All, First, Retry, Waterfall etc., that makes asynchronous flow control more intuitive.
Stars: ✭ 94 (+54.1%)
Mutual labels:  channel
mqtt-broker
A tokio-based MQTT v5 broker written in pure Rust [WIP]
Stars: ✭ 110 (+80.33%)
Mutual labels:  broker
smartacus-mqtt-broker
smartacus-mqtt-broker is a Java-based open source MQTT broker that fully supports MQTT 3.x .Using Netty 4.1.37
Stars: ✭ 25 (-59.02%)
Mutual labels:  broker
fritz
Astronomical data platform for the Zwicky Transient Facility.
Stars: ✭ 20 (-67.21%)
Mutual labels:  broker
context
A proof of concept implementation of scoped context
Stars: ✭ 16 (-73.77%)
Mutual labels:  goroutine
Mida
The open-source and cross-platform trading framework
Stars: ✭ 263 (+331.15%)
Mutual labels:  broker
errgroup
errgroup with goroutine worker limits
Stars: ✭ 143 (+134.43%)
Mutual labels:  goroutine
noroutine
Goroutine analogue for Node.js, spreads I/O-bound routine calls to utilize thread pool (worker_threads) using balancer with event loop utilization. 🌱
Stars: ✭ 86 (+40.98%)
Mutual labels:  goroutine
WormHole
WormHole allows to share classes between Flutter and Native Platform (android / ios)
Stars: ✭ 36 (-40.98%)
Mutual labels:  channel
Channel-Message-Editor
A telegram channel message editor bot.
Stars: ✭ 21 (-65.57%)
Mutual labels:  channel
ray-tracing
This is a go implementation of the "Ray Tracing in One Weekend" book
Stars: ✭ 37 (-39.34%)
Mutual labels:  goroutine
waldur-mastermind
Waldur MasterMind is a hybrid cloud orchestrator.
Stars: ✭ 37 (-39.34%)
Mutual labels:  broker
IotHub
Cloud based IoT system solution. MQTT Broker, MQTT Agent, SignalR Hub, Data Source API
Stars: ✭ 34 (-44.26%)
Mutual labels:  broker
go-workshops
Go language basic workshops for devz
Stars: ✭ 68 (+11.48%)
Mutual labels:  goroutine
ecs
Build your own Game-Engine based on the Entity Component System concept in Golang.
Stars: ✭ 68 (+11.48%)
Mutual labels:  goroutine

Introduction

chanbroker, a Broker for goroutine, is simliar to kafka

In chanbroker has three types of goroutine:

  • Producer
  • Consumer(Subscriber)
  • Broker

Document

参考godoc

Usage

code:

package main

import (
    "fmt"
    "github.com/myself659/chanbroker"
    "time"
)

type event struct {
    id   int
    info string
}

func subscriberDo(sub chanbroker.Subscriber, b *chanbroker.Broker, id int) {
    for {
        select {
        case c := <-sub:
            switch t := c.(type) {
            case event:
                fmt.Println("SubscriberId:", id, " event:", t)
            default:
            }
        }
    }

}

func publisherDo(b *chanbroker.Broker) {
    ticker := time.NewTicker(time.Second)
    i := 0
    for range ticker.C {
        ev := event{i, "event"}
        b.PubContent(ev)
        fmt.Println("Publisher:", ev)
        i++
        if 3 == i {
            break
        }
    }
    ticker.Stop()

    b.StopBroker()
}

func main() {
    // launch broker goroutine
    b := chanbroker.NewBroker(time.Second)

    // register  Subscriber and launch  Subscriber goroutine

    sub1, _ := b.RegSubscriber(1)

    go subscriberDo(sub1, b, 1)

    sub2, _ := b.RegSubscriber(1)

    go subscriberDo(sub2, b, 2)

    // launch Publisher goroutine

    go publisherDo(b)

    // after 3.5s, exit process
    <-time.After(3500 * time.Millisecond)

    fmt.Println("exit")
}

output:

Publisher: {0 event}
SubscriberId: 1  event: {0 event}
SubscriberId: 2  event: {0 event}
Publisher: {1 event}
SubscriberId: 2  event: {1 event}
SubscriberId: 1  event: {1 event}
Publisher: {2 event}
SubscriberId: 2  event: {2 event}
SubscriberId: 1  event: {2 event}
exit
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].