当前位置: 首页 > 软件库 > 程序开发 > 网络工具包 >

emitter

授权协议 AGPL-3.0 License
开发语言 Google Go
所属分类 程序开发、 网络工具包
软件类型 开源软件
地区 不详
投 递 者 竺承望
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

kelindar/column
Go VersionGo Report CardCoverageTwitter

Emitter: Distributed Publish-Subscribe Platform

Emitter is a distributed, scalable and fault-tolerant publish-subscribe platform built with MQTT protocol and featuring message storage, security, monitoring and more:

  • Publish/Subscribe using MQTT over TCP or Websockets.
  • Resilient, highly available and partition tolerant (AP in CAP terms).
  • Able to handle 3+ million of messages/sec on a single broker.
  • Supports message storage with history and message-level expiry.
  • Provides secure channel keys with permissions and can face the internet.
  • Automatic TLS/SSL and encrypted inter-broker communication.
  • Built-in monitoring with Prometheus, StatsD and more.
  • Shared subscriptions, links and private links for channels.
  • Easy deployment with Docker and Kubernetes of production-ready clusters.

Emitter can be used for online gaming and mobile apps by satisfying the requirements for low latency, binary messaging and high throughput. It can also be used for the real-time web application such as dashboards or visual analytics or chat systems. Moreover, Emitter is perfect for the internet of things and allows sensors to be controlled and data gathered and analyzed.

Tutorials & Demos

The following video tutorials demonstrate various features of Emitter in action.

FOSDEM 2018FOSDEM 2019PubSub in GoMessage StorageUsing MQTTSpyISS TrackingSelf-Signed TLSMonitor with eTopStatsD and DataDogLinks & Private LinksBuilding a Client-Server app with Publish-Subscribe in GoDistributed Actor Model with Publish/Subscribe and GolangOnline Multiplayer Platformer Game with EmitterKeeping one Last Message per Channel using MQTT RetainLoad-balance Messages using Subscriber Groups

How to Deploy

Local Emitter ClusterK8s and DigitalOceanK8s and Google CloudK8s and Azure

Quick Start

Run Server

The quick way to start an Emitter broker is by using docker run command as shown below.

Notice: You must use -e for docker environment.You could get it from your docker log.

docker run -d --name emitter -p 8080:8080 --restart=unless-stopped emitter/server

Alternatively, you might compile this repository and use go get command to rebuild and run from source.

go get -u github.com/emitter-io/emitter && emitter

Get License

Both commands above start a new server and if no configuration or environment variables were supplied, it will print out a message(or you could find it in the docker log) similar to the message below once the server has started :

[service] unable to find a license, make sure 'license' value is set in the config file or EMITTER_LICENSE environment variable
[service] generated new license: uppD0PFIcNK6VY-7PTo7uWH8EobaOGgRAAAAAAAAAAI
[service] generated new secret key: JUoOxjoXLc4muSxXynOpTc60nWtwUI3o

This message shows that a new security configuration was generated, you can then re-run EMITTER_LICENSE set to the specified value. Alternatively, you can set "license" property in the emitter.conf configuration file.

Re-Run Command

References are available. Please replace your EMITTER_LICENSE to it.

docker run -d --name emitter -p 8080:8080 -e EMITTER_LICENSE=uppD0PFIcNK6VY-7PTo7uWH8EobaOGgRAAAAAAAAAAI --restart=unless-stopped emitter/server

Generate Key

Finally, open a browser and navigate to http://127.0.0.1:8080/keygen in order to generate your key. Now you can use the secret key generated to create channel keys, which allow you to secure individual channels and start using emitter.

Warning: If you use upon command, you secret is JUoOxjoXLc4muSxXynOpTc60nWtwUI3o. And it's not safe!!!

Usage Example

The code below shows a small example of usage of emitter with the Javascript SDK. As you can see, the API exposes straightforward methods such as publish and subscribe which can take binary payload and are secured through channel keys.

// connect to emitter service
var connection = emitter.connect({ host: '127.0.0.1' });

// once we're connected, subscribe to the 'chat' channel
emitter.on('connect', function(){
    emitter.subscribe({
        key: "<channel key>",
        channel: "chat"
    });
});

// publish a message to the chat channel
emitter.publish({
    key: "<channel key>",
    channel: "chat/my_name",
    message: "hello, emitter!"
});

Further documentation, demos and language/platform SDKs are available in the develop section of our website. Make sure to check out the getting started tutorial which explains the basic usage of emitter and MQTT.

Command line arguments

The Emitter broker accepts command line arguments, allowing you to specify a configuration file, usage is shown below.

-config string
   The configuration file to use for the broker. (default "emitter.conf")

-help
   Shows the help and usage instead of running the broker.

Configuration File

The configuration file (defaulting to emitter.conf) is the main way of configuring the broker. The configuration file is however, not the only way of configuring it as it allows a multi-level override through environment variables and/or hashicorp Vault.

The configuration file is in JSON format, but you can override any value by providing an environment variable which follows a particular format, for example if you'd like to provide a license through environment variable, simply define EMITTER_LICENSE environment variable, similarly, if you want to specify a certificate, define EMITTER_TLS_CERTIFICATE environment variable. Example of configuration file:

{
    "listen": ":8080",
    "license": "/*The license*/",
    "tls": {
        "listen": ":443",
        "host": "example.com"
    },
    "cluster": {
        "listen": ":4000",
        "seed": " 192.168.0.2:4000",
        "advertise": "public:4000"
    },
    "storage": {
        "provider": "inmemory"
    }
}

The structure of the configuration is described below:

Property Env. Variable Description
license EMITTER_LICENSE The license file to use for the broker. This contains the encryption key.
listen EMITTER_LISTEN The API address used for TCP & Websocket communication, in IP:PORT format (e.g: :8080).
limit.messageSize EMITTER_LIMIT_MESSAGESIZE Maximum message size. Default is 64KB.
tls.listen EMITTER_TLS_LISTEN The API address used for Secure TCP & Websocket communication, in IP:PORT format (e.g: :443).
tls.host EMITTER_TLS_HOST The hostname to whitelist for the certificate.
tls.email EMITTER_TLS_EMAIL The email account to use for autocert.
vault.address EMITTER_VAULT_ADDRESS The Hashicorp Vault address to use to further override configuration.
vault.app EMITTER_VAULT_APP The Hashicorp Vault application ID to use.
cluster.name EMITTER_CLUSTER_NAME The name of this node. This must be unique in the cluster. If this is not set, Emitter will set it to the external IP address of the running machine.
cluster.listen EMITTER_CLUSTER_LISTEN The IP address and port that is used to bind the inter-node communication network. This is used for the actual binding of the port.
cluster.advertise EMITTER_CLUSTER_ADVERTISE The address and port to advertise inter-node communication network. This is used for nat traversal.
cluster.seed EMITTER_CLUSTER_SEED The seed address (or a domain name) for cluster join.
cluster.passphrase EMITTER_CLUSTER_PASSPHRASE Passphrase is used to initialize the primary encryption key in a keyring. This key is used for encrypting all the gossip messages (message-level encryption).
storage.provider EMITTER_STORAGE_PROVIDER This property represents the publishers publish message storage mode. there are two kinds of can use, they are respectively inmemory and ssd, defaults to the former.
storage.config.dir EMITTER_STORAGE_CONFIG If the storage mode is ssd, this property indicates where the messages are stored (emitter server nodes are not allowed to use the same directory within the same machine)

Building and Testing

The server requires Golang 1.9 to be installed. Once you have this installed, simply go get this repository and run the following commands to download the package and run the server.

go get -u github.com/emitter-io/emitter && emitter

If you want to run the tests, simply run go test command as demonstrated below.

go test ./...

Deploying as Docker Container

Docker Automated buildDocker Pulls

Emitter is conveniently packaged as a docker container. To run the emitter service on a single server, use the command below. Once the server is started, it will generate a new security configuration, you can then re-run the same command with an additional environment variable -e EMITTER_LICENSE set to the provided value.

docker run -d -p 8080:8080 emitter/server

For the clustered (multi-server) mode, the container can be started using the simple docker run with 3 main parameters.

docker run -d -p 8080:8080 -p 4000:4000 -e EMITTER_LICENSE=[key] -e EMITTER_CLUSTER_SEED=[seed] -e EMITTER_CLUSTER_PASSPHRASE=[name] emitter/server

Support, Discussion, and Community

Join the chat at https://gitter.im/emitter-io/public

If you need any help with Emitter Server or any of our client SDKs, please join us at either our gitter chat where most of our team hangs out at or drop us an e-mail at info@emitter.io.

Please submit any Emitter bugs, issues, and feature requests to emitter-io>emitter. If there are any security issues, please email info@emitter.io instead of posting an open issue in Github.

Contributing

If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are warmly welcome.

Licensing

Copyright (c) 2009-2019 Misakai Ltd. This project is licensed under Affero General Public License v3.

Emitter offers support contracts and is now also offered via a commercial license. Please contact info@emitter.io for more information.

  • 最近使用event-emitter比较多,特地去查看了相关源码和加上自己的理解,写下点笔记, 各位大佬觉得写得有错的指教一下,谢谢。 参考资料: Event emitter的监听事件:https://www.php.cn/xiaochengxu-391850.html JS的EventEmitter使用步奏详解:https://www.php.cn/xiaochengxu-391849.html

  • 定义Emitter // 定义Emitter staffEmitter = new EventEmitter(); // 获取Emitter getStaffEmitter(): EventEmitter<{}> { return this.staffEmitter ; } // 触发Emitter emitStaffEmitter(): void { this.sta

  • 本文参加了由公众号@若川视野发起的每周源码共读活动,点击了解详情一起参与。 1. 前言 这次学习的项目是 mitt tiny-emitter 1.1 你能学到 发布订阅模式 了解 mitt、tiny-emitter 用法 以及他们的应用场景 具体实现 2. 这个库,是干啥的 老规矩,先看README mitt Tiny 200b functional event emitter / pubsu

  • A tiny (less than 1k) event emitter library 文档 github: https://github.com/scottcorgan/tiny-emitter 安装 npm install tiny-emitter --save 使用示例 import Emitter from 'tiny-emitter' const emitter = new Emi

  • tiny-emitter 源码解析 正文 0. 关于 Emitter tiny-emitter 是 Node 提供的 EventEmitter 的简单版本,也就是面试的时候常见的 Emitter 实现 1. 源码结构 tiny-emitter 的源码就只有一个 index.js 文件 /index.js(阅读笔记:/index.js/1_structure.js) function E () {

 相关资料
  • 本文向大家介绍node.js中的emitter.emit方法使用说明,包括了node.js中的emitter.emit方法使用说明的使用技巧和注意事项,需要的朋友参考一下 方法说明: 发射event事件,传递若干可选参数到事件监听器的参数表。 语法: 接收参数: event                      事件类型 arg1 ~ argN           传递的参数(多个) 例子:

  • 本文向大家介绍node.js中的emitter.on方法使用说明,包括了node.js中的emitter.on方法使用说明的使用技巧和注意事项,需要的朋友参考一下 方法说明: 为指定事件注册一个监听器。 语法: 接收参数: event            (string)             事件类型 listener         (function)         触发事件时的回调函

  • 问题内容: 当我使用node.js’request’模块对某个URI进行GET时; 错误消息是: 并且还有以下消息: 我该怎么办? 问题答案: 我强烈建议不要使用以下代码: 没有合理的警告。在大多数情况下,这是因为代码中隐藏了错误。取消限制将消除警告,但不会消除其原因,并防止警告您资源泄漏的源头。 如果您出于正当理由达到了限制,请在函数中输入一个合理的值(默认值为10)。 同样,要更改默认值,也不

  • 一个示例项目位于以下位置:https://github.com/codependent/spring5-playground ...但是很多时候它没有得到任何东西。

  • 我正在使用BIRT运行时引擎4.2.1 1.我已将以下jar移动到birt-runtime-4_2_1\ReportEngine\lib文件夹2.更改代码以使用spudsoft发射器`公共类RunReport{ 执行报表时收到以下错误。 我错过了任何步骤或配置吗! 注意:我正在尝试使用spudsoft发射器作为默认发射器,打开excel时出现以下错误提示。

  • 目前,我正在尝试在Kotlin编写基于Maven、Quarkus和SmallRye Reactive Messaging的“通知服务”。作为基础,我在Java中有一个很好的例子,我试图将其“翻译”成Kotlin。 我希望它的工作方式是,我发送一个HTTP请求(例如GET http://localhost:8080/search/{word}),系统将“单词”(这里是字符串)发送到Artemis A

  • fis. emitter 事件监听器, fis 中所有的事件都通过它来监听和触发。 Source: fis.js, line 76 See: https://nodejs.org/api/events.html

  • Node中的许多对象都会发出事件,例如net.Server每次对等体连接它时都会发出一个事件,fs.readStream会在打开文件时发出事件。 发出事件的所有对象都是events.EventEmitter的实例。 EventEmitter类 正如我们在上一节中看到的,EventEmitter类位于events模块中。 可通过以下代码访问 - // Import events module var

相关阅读

相关文章

相关问答

相关文档