summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2019-05-02 18:35:18 +0300
committerWolfy-J <[email protected]>2019-05-02 18:35:18 +0300
commitb3e7bbccdd7636b6ce7d90cf4f295e498feb719c (patch)
tree4db686c678bf7e4ee4e69e4443f34c46d7f26bea
parenteb8c64941cbcd30ff79b6147efd5fef42eccb648 (diff)
miiiinor performance optimizations
-rw-r--r--protocol.go4
-rw-r--r--protocol_test.go2
-rw-r--r--worker.go5
3 files changed, 6 insertions, 5 deletions
diff --git a/protocol.go b/protocol.go
index 564df9b7..5523a3e5 100644
--- a/protocol.go
+++ b/protocol.go
@@ -15,7 +15,7 @@ type pidCommand struct {
Pid int `json:"pid"`
}
-func sendPayload(rl goridge.Relay, v interface{}) error {
+func sendControl(rl goridge.Relay, v interface{}) error {
if data, ok := v.([]byte); ok {
return rl.Send(data, goridge.PayloadControl|goridge.PayloadRaw)
}
@@ -29,7 +29,7 @@ func sendPayload(rl goridge.Relay, v interface{}) error {
}
func fetchPID(rl goridge.Relay) (pid int, err error) {
- if err := sendPayload(rl, pidCommand{Pid: os.Getpid()}); err != nil {
+ if err := sendControl(rl, pidCommand{Pid: os.Getpid()}); err != nil {
return 0, err
}
diff --git a/protocol_test.go b/protocol_test.go
index ed3fe461..526945cb 100644
--- a/protocol_test.go
+++ b/protocol_test.go
@@ -29,7 +29,7 @@ func (r *relayMock) Close() error {
}
func Test_Protocol_Errors(t *testing.T) {
- err := sendPayload(&relayMock{}, make(chan int))
+ err := sendControl(&relayMock{}, make(chan int))
assert.Error(t, err)
}
diff --git a/worker.go b/worker.go
index 7221c2de..b01b362a 100644
--- a/worker.go
+++ b/worker.go
@@ -137,7 +137,7 @@ func (w *Worker) Stop() error {
defer w.mu.Unlock()
w.state.set(StateStopping)
- err := sendPayload(w.rl, &stopCommand{Stop: true})
+ err := sendControl(w.rl, &stopCommand{Stop: true})
<-w.waitDone
return err
@@ -221,7 +221,8 @@ func (w *Worker) start() error {
}
func (w *Worker) execPayload(rqs *Payload) (rsp *Payload, err error) {
- if err := sendPayload(w.rl, rqs.Context); err != nil {
+ // two things
+ if err := sendControl(w.rl, rqs.Context); err != nil {
return nil, errors.Wrap(err, "header error")
}