summaryrefslogtreecommitdiff
path: root/server.go
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-06-05 22:48:27 +0300
committerWolfy-J <[email protected]>2018-06-05 22:48:27 +0300
commit6adaf713b47c9a3ab3a516e21d2d4ecf7f2075d6 (patch)
tree6bcf1bfea1e2f87a3ae7065612c0df43c90c1cdc /server.go
parent3112f9b58c73773cea972fd79f04d33f8f7d7edd (diff)
breaking the tests
Diffstat (limited to 'server.go')
-rw-r--r--server.go30
1 files changed, 22 insertions, 8 deletions
diff --git a/server.go b/server.go
index f6b82bad..9a24cb39 100644
--- a/server.go
+++ b/server.go
@@ -16,14 +16,14 @@ const (
// Service manages pool creation and swapping.
type Server struct {
- // observes pool events (can be attached to multiple pools at the same time)
- observer func(event int, ctx interface{})
-
// worker command creator
cmd func() *exec.Cmd
- // pool behaviour
- cfg Config
+ // defines server wide configuration, behaviour and timeouts.
+ config ServerConfig
+
+ // observes pool events (can be attached to multiple pools at the same time)
+ observer func(event int, ctx interface{})
// creates and connects to workers
factory Factory
@@ -31,6 +31,9 @@ type Server struct {
// protects pool while the switch
mu sync.Mutex
+ // pool behaviour
+ cfg Config
+
// currently active pool instance
pool Pool
}
@@ -128,12 +131,23 @@ func (r *Server) Destroy() {
r.pool = nil
}
-func (r *Server) Start() {
- // ????
+// Start the server underlying worker pool and factory.
+func (r *Server) Start() error {
+ if r.factory != nil {
+ //todo: already have started
+ return nil
+ }
+
+ return nil
}
+// Stop the server and close underlying factory.
func (r *Server) Stop() {
- // stop factory?
+ r.mu.Lock()
+ defer r.mu.Unlock()
+
+ r.factory.Close()
+ r.factory = nil
}
// throw invokes event handler if any.