summaryrefslogtreecommitdiff
path: root/service/rpc.go
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-06-03 12:54:43 +0300
committerWolfy-J <[email protected]>2018-06-03 12:54:43 +0300
commit36ea77baa5a41de10bd604cd0e5b5b3cafaaeb64 (patch)
tree13ca8abd454a6668f490eec2e44b1520bd3953fe /service/rpc.go
parentb02611b7266589d888e054a1d2e4432ae370617d (diff)
service bus, http service, rpc bus, cli commands, new configs
Diffstat (limited to 'service/rpc.go')
-rw-r--r--service/rpc.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/service/rpc.go b/service/rpc.go
new file mode 100644
index 00000000..eb128768
--- /dev/null
+++ b/service/rpc.go
@@ -0,0 +1,32 @@
+package service
+
+import (
+ "net"
+ "strings"
+)
+
+type RPCConfig struct {
+ Listen string
+}
+
+func (cfg *RPCConfig) CreateListener() (net.Listener, error) {
+ dsn := strings.Split(cfg.Listen, "://")
+ if len(dsn) != 2 {
+ return nil, dsnError
+ }
+
+ return net.Listen(dsn[0], dsn[1])
+}
+
+func (cfg *RPCConfig) CreateDialer() (net.Conn, error) {
+ dsn := strings.Split(cfg.Listen, "://")
+ if len(dsn) != 2 {
+ return nil, dsnError
+ }
+
+ return net.Dial(dsn[0], dsn[1])
+}
+
+func NewBus() *Bus {
+ return &Bus{services: make([]Service, 0)}
+}