pb-pubsub/

directory
v0.0.0-...-1a196e1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2017 License: MIT

README

pb-pubsub

這個範例是基於 nsq-pubsub,不過這次傳遞的內容從基本的純文字改成 Protobuf 內容。

範例

# 啟動生產者,這會向 NSQ 傳送一個 Protobuf 資料到 `msg` 主題。
go run ./producer/main.go
# 啟動消費者,這會向 NSQ 註冊一個基於 `msg` 主題的 `user` 頻道,
# 所以就能接收 `msg` 主題的訊息,接著透過 Protobuf 解碼。
go run ./consumer/main.go
2017/03/14 04:17:09 INF    2 [msg/user] querying nsqlookupd http://127.0.0.1:4161/lookup?topic=msg
2017/03/14 04:17:09 INF    2 [msg/user] (127.0.0.1:4150) connecting to nsqd
2017/03/14 04:17:14 接收到了一個 Protobuf 資料,而 Content 是:你好,世界!

Protobuf

// Msg 呈現了一個訊息資料。
message Msg {
    string content = 1;
}

Directories

Path Synopsis
Package pb is a generated protocol buffer package.
Package pb is a generated protocol buffer package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL