diff --git a/examples/main.go b/examples/eventbus/eventbus.go similarity index 100% rename from examples/main.go rename to examples/eventbus/eventbus.go diff --git a/examples/networkbus/client/client.go b/examples/networkbus/client/client.go new file mode 100644 index 0000000..57f6fdc --- /dev/null +++ b/examples/networkbus/client/client.go @@ -0,0 +1,12 @@ +package main + +import ( + goeventbus "github.com/stanipetrosyan/go-eventbus" +) + +var eventbus = goeventbus.NewEventBus() + +func main() { + network := goeventbus.NewNetworkBus(eventbus, "localhost", "/bus") + network.Client() +} diff --git a/examples/networkbus/server/server.go b/examples/networkbus/server/server.go new file mode 100644 index 0000000..a87135e --- /dev/null +++ b/examples/networkbus/server/server.go @@ -0,0 +1,12 @@ +package main + +import ( + goeventbus "github.com/stanipetrosyan/go-eventbus" +) + +var eventbus = goeventbus.NewEventBus() + +func main() { + network := goeventbus.NewNetworkBus(eventbus, "localhost", "/bus") + network.Server() +} diff --git a/network_bus.go b/network_bus.go new file mode 100644 index 0000000..453279e --- /dev/null +++ b/network_bus.go @@ -0,0 +1,20 @@ +package goeventbus + +type NetworkBus interface { + Server() + Client() +} + +type defaultNetworkBus struct { + localBus EventBus + address string + path string +} + +func NewNetworkBus(bus EventBus, address, path string) NetworkBus { + return defaultNetworkBus{localBus: bus, address: address, path: path} +} + +func (b defaultNetworkBus) Server() {} + +func (b defaultNetworkBus) Client() {}