Skip to content

Commit

Permalink
init network bus interface and added new example
Browse files Browse the repository at this point in the history
  • Loading branch information
stanipetrosyan committed Apr 9, 2024
1 parent 122fb7c commit abc0ccc
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
File renamed without changes.
12 changes: 12 additions & 0 deletions examples/networkbus/client/client.go
Original file line number Diff line number Diff line change
@@ -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()
}
12 changes: 12 additions & 0 deletions examples/networkbus/server/server.go
Original file line number Diff line number Diff line change
@@ -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()
}
20 changes: 20 additions & 0 deletions network_bus.go
Original file line number Diff line number Diff line change
@@ -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() {}

0 comments on commit abc0ccc

Please sign in to comment.