Skip to content

Commit

Permalink
added server and client interface
Browse files Browse the repository at this point in the history
  • Loading branch information
stanipetrosyan committed Apr 11, 2024
1 parent abc0ccc commit f7345ad
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 6 deletions.
15 changes: 15 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package goeventbus

type Client interface {
Connect()
}

type tcpClient struct {
}

func (s tcpClient) Connect() {
}

func NewClient() Client {
return tcpClient{}
}
3 changes: 2 additions & 1 deletion examples/networkbus/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ var eventbus = goeventbus.NewEventBus()

func main() {
network := goeventbus.NewNetworkBus(eventbus, "localhost", "/bus")
network.Client()

network.Client().Connect()
}
2 changes: 1 addition & 1 deletion examples/networkbus/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ var eventbus = goeventbus.NewEventBus()

func main() {
network := goeventbus.NewNetworkBus(eventbus, "localhost", "/bus")
network.Server()
network.Server().Listen()
}
12 changes: 8 additions & 4 deletions network_bus.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package goeventbus

type NetworkBus interface {
Server()
Client()
Server() Server
Client() Client
}

type defaultNetworkBus struct {
Expand All @@ -15,6 +15,10 @@ func NewNetworkBus(bus EventBus, address, path string) NetworkBus {
return defaultNetworkBus{localBus: bus, address: address, path: path}
}

func (b defaultNetworkBus) Server() {}
func (b defaultNetworkBus) Server() Server {
return NewServer()
}

func (b defaultNetworkBus) Client() {}
func (b defaultNetworkBus) Client() Client {
return NewClient()
}
15 changes: 15 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package goeventbus

type Server interface {
Listen()
}

type tcpServer struct {
}

func (s tcpServer) Listen() {
}

func NewServer() Server {
return tcpServer{}
}

0 comments on commit f7345ad

Please sign in to comment.