diff --git a/adapter/fasthttp/adapter.go b/adapter/fasthttp/adapter.go index 842d513..ebb590f 100644 --- a/adapter/fasthttp/adapter.go +++ b/adapter/fasthttp/adapter.go @@ -16,7 +16,7 @@ type FastHTTPAdapter struct { // FastHTTPHandler func (a *FastHTTPAdapter) FastHTTPHandler(ctx *fasthttp.RequestCtx) { if !ctx.IsPost() { - WriteError(ctx, 405, "rpc: POST method required, received "+r.Method) + writeError(ctx, 405, "rpc: POST method required, received "+string(ctx.Method())) return } @@ -26,11 +26,11 @@ func (a *FastHTTPAdapter) FastHTTPHandler(ctx *fasthttp.RequestCtx) { contentType = contentType[:idx] } - err := a.registry.Invoke(contentType, ctx.PostBody(), ctx, beforeWrite, afterWrite) + // err := a.registry.Invoke(contentType, ctx.Request., ctx, beforeWrite, afterWrite) - if nil != err { - WriteError(w, 400, err.Error()) - } + // if nil != err { + // writeError(ctx, 400, err.Error()) + // } } diff --git a/adapter/ipc/adapter.go b/adapter/ipc/adapter.go new file mode 100644 index 0000000..89b0605 --- /dev/null +++ b/adapter/ipc/adapter.go @@ -0,0 +1,13 @@ +package ipc + +import "git.loafle.net/commons_go/rpc" + +type IPCAdapter struct { + registry rpc.Registry +} + +func NewAdapter(registry rpc.Registry) *IPCAdapter { + return &IPCAdapter{ + registry: registry, + } +} diff --git a/adapter/ipc/ipc.go b/adapter/ipc/ipc.go new file mode 100644 index 0000000..b0092ac --- /dev/null +++ b/adapter/ipc/ipc.go @@ -0,0 +1,14 @@ +package ipc + +import ( + "git.loafle.net/commons_go/rpc" + "git.loafle.net/commons_go/server" +) + +func NewServer(addr string, registry rpc.Registry) server.Server { + sh := NewServerHandler(addr) + + s := server.NewServer(sh) + + return s +} diff --git a/adapter/ipc/server_handlers.go b/adapter/ipc/server_handlers.go new file mode 100644 index 0000000..7ed2da6 --- /dev/null +++ b/adapter/ipc/server_handlers.go @@ -0,0 +1,32 @@ +package ipc + +import ( + "io" + + "git.loafle.net/commons_go/rpc" + "git.loafle.net/commons_go/server" + "git.loafle.net/commons_go/server/ipc" +) + +func NewServerHandler(addr string, registry rpc.Registry) ServerHandler { + sh := &ServerHandlers{ + registry: registry, + } + sh.Addr = addr + + return sh +} + +type ServerHandler interface { + server.ServerHandler +} + +type ServerHandlers struct { + ipc.ServerHandlers + + registry rpc.Registry +} + +func (sh *ServerHandlers) Handle(remoteAddr string, rwc io.ReadWriteCloser, stopChan chan struct{}) { + +} diff --git a/glide.yaml b/glide.yaml index d5c64ce..d4f5bff 100644 --- a/glide.yaml +++ b/glide.yaml @@ -2,3 +2,5 @@ package: git.loafle.net/commons_go/rpc import: - package: github.com/valyala/fasthttp version: v20160617 +- package: git.loafle.net/commons_go/server +- package: gopkg.in/natefinch/npipe.v2