Skip to content

Commit

Permalink
Merge pull request #5 from IoTMOD/fix/zmq
Browse files Browse the repository at this point in the history
Add configurable ZMQ protocols and host
  • Loading branch information
muXxer authored Dec 12, 2019
2 parents bf47b92 + 58133b6 commit 1558d39
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 3 additions & 1 deletion plugins/zeromq/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ package zeromq
import flag "github.com/spf13/pflag"

func init() {
flag.Int("zmq.port", 5556, "tcp port used to connect to the zmq feed")
flag.String("zmq.protocol", "tcp", "protocol used to connect to the zmq feed [unix, tcp, udp, inproc]")
flag.String("zmq.host", "0.0.0.0", "host used to connect to the zmq feed")
flag.Int("zmq.port", 5556, "port used to connect to the zmq feed")
}
8 changes: 4 additions & 4 deletions plugins/zeromq/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ package zeromq
import (
"time"

daemon "github.com/iotaledger/hive.go/daemon/ordered"
"github.com/iotaledger/hive.go/events"
"github.com/iotaledger/hive.go/parameter"
"github.com/gohornet/hornet/packages/logger"
"github.com/gohornet/hornet/packages/model/hornet"
"github.com/gohornet/hornet/packages/model/milestone_index"
Expand All @@ -15,6 +12,9 @@ import (
"github.com/gohornet/hornet/packages/timeutil"
"github.com/gohornet/hornet/packages/workerpool"
"github.com/gohornet/hornet/plugins/tangle"
daemon "github.com/iotaledger/hive.go/daemon/ordered"
"github.com/iotaledger/hive.go/events"
"github.com/iotaledger/hive.go/parameter"
)

const (
Expand Down Expand Up @@ -180,5 +180,5 @@ func startPublisher() error {
}
publisher = pub

return publisher.Start(parameter.NodeConfig.GetInt("zmq.port"))
return publisher.Start()
}
6 changes: 4 additions & 2 deletions plugins/zeromq/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"

zmq "github.com/go-zeromq/zmq4"
"github.com/iotaledger/hive.go/parameter"
)

// Publisher is a simple zmq publisher abstraction
Expand All @@ -24,8 +25,9 @@ func NewPublisher() (*Publisher, error) {
}

// Start the publisher on the given port.
func (pub *Publisher) Start(port int) error {
return pub.socket.Listen("tcp://*:" + strconv.Itoa(port))
func (pub *Publisher) Start() error {
endpoint := parameter.NodeConfig.GetString("zmq.protocol") + "://" + parameter.NodeConfig.GetString("zmq.host") + ":" + strconv.Itoa(parameter.NodeConfig.GetInt("zmq.port"))
return pub.socket.Listen(endpoint)
}

// Shutdown stops the publisher.
Expand Down

0 comments on commit 1558d39

Please sign in to comment.