summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-06-11 12:13:36 +0300
committerWolfy-J <[email protected]>2018-06-11 12:13:36 +0300
commitefcddcc8d1b676c64cbd41a5f645bd046ba416d7 (patch)
tree8e51cde97920e62fcb03ad955933194d4af1b809
parent4e54066384b1f2cfb6684c781976d3a9288f1f7e (diff)
no more updated
-rw-r--r--cmd/rr/main.go10
-rw-r--r--service/http/rpc.go4
-rw-r--r--state.go13
-rw-r--r--state_test.go1
-rw-r--r--worker_test.go19
5 files changed, 2 insertions, 45 deletions
diff --git a/cmd/rr/main.go b/cmd/rr/main.go
index 07448feb..470e4795 100644
--- a/cmd/rr/main.go
+++ b/cmd/rr/main.go
@@ -36,23 +36,13 @@ import (
"github.com/spf13/cobra"
_ "net/http/pprof"
- "os"
"log"
- "runtime/pprof"
"net/http"
)
var debugMode bool
func main() {
- f, err := os.Create("cpu.pprof")
- if err != nil {
- log.Fatal(err)
- }
-
- pprof.StartCPUProfile(f)
- defer pprof.StopCPUProfile()
-
go func() {
log.Println(http.ListenAndServe("localhost:6060", nil))
}()
diff --git a/service/http/rpc.go b/service/http/rpc.go
index 2adb8706..aa68a826 100644
--- a/service/http/rpc.go
+++ b/service/http/rpc.go
@@ -25,9 +25,6 @@ type Worker struct {
// Created is unix nano timestamp of worker creation time.
Created int64 `json:"created"`
-
- // Updated is unix nano timestamp of last worker execution.
- Updated int64 `json:"updated"`
}
// Reset resets underlying RR worker pool and restarts all of it's workers.
@@ -53,7 +50,6 @@ func (rpc *rpcServer) Workers(list bool, r *WorkerList) error {
Status: state.String(),
NumJobs: state.NumExecs(),
Created: w.Created.UnixNano(),
- Updated: state.Updated().UnixNano(),
})
}
diff --git a/state.go b/state.go
index 61e48231..4a1a8384 100644
--- a/state.go
+++ b/state.go
@@ -3,7 +3,6 @@ package roadrunner
import (
"fmt"
"sync/atomic"
- "time"
)
// State represents worker status and updated time.
@@ -15,9 +14,6 @@ type State interface {
// NumJobs shows how many times worker was invoked
NumExecs() int64
-
- // Updated indicates a moment updated last state change
- Updated() time.Time
}
const (
@@ -43,11 +39,10 @@ const (
type state struct {
value int64
numExecs int64
- updated int64
}
func newState(value int64) *state {
- return &state{value: value, updated: time.Now().UnixNano()}
+ return &state{value: value}
}
// String returns current state as string.
@@ -79,11 +74,6 @@ func (s *state) IsActive() bool {
return state == StateWorking || state == StateReady
}
-// Updated indicates a moment updated last state change
-func (s *state) Updated() time.Time {
- return time.Unix(0, atomic.LoadInt64(&s.updated))
-}
-
func (s *state) NumExecs() int64 {
return atomic.LoadInt64(&s.numExecs)
}
@@ -91,7 +81,6 @@ func (s *state) NumExecs() int64 {
// change state value (status)
func (s *state) set(value int64) {
atomic.StoreInt64(&s.value, value)
- atomic.StoreInt64(&s.updated, time.Now().UnixNano())
}
// register new execution atomically
diff --git a/state_test.go b/state_test.go
index be63230e..c13c5a88 100644
--- a/state_test.go
+++ b/state_test.go
@@ -9,7 +9,6 @@ func Test_NewState(t *testing.T) {
st := newState(StateErrored)
assert.Equal(t, "errored", st.String())
- assert.NotEqual(t, 0, st.Updated().Unix())
assert.Equal(t, "inactive", newState(StateInactive).String())
assert.Equal(t, "ready", newState(StateReady).String())
diff --git a/worker_test.go b/worker_test.go
index 6e65c998..2e3bc111 100644
--- a/worker_test.go
+++ b/worker_test.go
@@ -4,7 +4,6 @@ import (
"github.com/stretchr/testify/assert"
"os/exec"
"testing"
- "time"
)
func Test_GetState(t *testing.T) {
@@ -191,20 +190,4 @@ func Test_NumExecs(t *testing.T) {
w.Exec(&Payload{Body: []byte("hello")})
assert.Equal(t, int64(3), w.State().NumExecs())
-}
-
-func Test_StateUpdated(t *testing.T) {
- cmd := exec.Command("php", "php-src/tests/client.php", "echo", "pipes")
-
- w, _ := NewPipeFactory().SpawnWorker(cmd)
- go func() {
- assert.NoError(t, w.Wait())
- }()
- defer w.Stop()
-
- tm := time.Now()
- time.Sleep(time.Millisecond)
-
- w.Exec(&Payload{Body: []byte("hello")})
- assert.True(t, w.State().Updated().After(tm))
-}
+} \ No newline at end of file