dropped fiber for std http + gorilla websocket

Session serialization will use gob encoding instead of json.
Binary size will likely be reduced.
General backend code refactoring.
This commit is contained in:
2023-07-26 11:48:54 +02:00
parent 82b22db7ae
commit e1510d28d2
11 changed files with 351 additions and 251 deletions

39
server/rpc/wrapper.go Normal file
View File

@@ -0,0 +1,39 @@
package rpc
import (
"bytes"
"io"
"net/rpc/jsonrpc"
)
// Wrapper for HTTP RPC request that implements io.Reader interface
type rpcRequest struct {
r io.Reader
rw io.ReadWriter
done chan bool
}
func newRequest(r io.Reader) *rpcRequest {
var buf bytes.Buffer
done := make(chan bool)
return &rpcRequest{r, &buf, done}
}
func (r *rpcRequest) Read(p []byte) (n int, err error) {
return r.r.Read(p)
}
func (r *rpcRequest) Write(p []byte) (n int, err error) {
return r.rw.Write(p)
}
func (r *rpcRequest) Close() error {
r.done <- true
return nil
}
func (r *rpcRequest) Call() io.Reader {
go jsonrpc.ServeConn(r)
<-r.done
return r.rw
}