summaryrefslogtreecommitdiff
path: root/server.go
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-06-10 17:04:02 +0300
committerWolfy-J <[email protected]>2018-06-10 17:04:02 +0300
commit3fe85e9d92f5f98337e8f7fd9a14e6b66b9694bd (patch)
tree2575fbba16df4f95dd392f231ad7d7b30a5dd4ef /server.go
parent4c292ee46f5505b00b16186e8f30e9bc1be25895 (diff)
http service
Diffstat (limited to 'server.go')
-rw-r--r--server.go22
1 files changed, 11 insertions, 11 deletions
diff --git a/server.go b/server.go
index fb6927d6..84dedb52 100644
--- a/server.go
+++ b/server.go
@@ -29,7 +29,7 @@ type Server struct {
cfg *ServerConfig
// observes pool events (can be attached to multiple pools at the same time)
- observer func(event int, ctx interface{})
+ listener func(event int, ctx interface{})
// protects pool while the re-configuration
mu sync.Mutex
@@ -49,9 +49,9 @@ func NewServer(cfg *ServerConfig) *Server {
return &Server{cfg: cfg}
}
-// Observe attaches server event watcher.
-func (srv *Server) Observe(o func(event int, ctx interface{})) {
- srv.observer = o
+// Listen attaches server event watcher.
+func (srv *Server) Listen(l func(event int, ctx interface{})) {
+ srv.listener = l
}
// Reconfigure re-configures underlying pool and destroys it's previous version if any. Reconfigure will ignore factory
@@ -80,7 +80,7 @@ func (srv *Server) Reconfigure(cfg *ServerConfig) error {
srv.mu.Lock()
srv.cfg.Pool, srv.pool = cfg.Pool, pool
- srv.pool.Observe(srv.poolObserver)
+ srv.pool.Listen(srv.poolListener)
srv.mu.Unlock()
srv.throw(EventPoolConstruct, pool)
@@ -113,7 +113,7 @@ func (srv *Server) Start() (err error) {
return err
}
- srv.pool.Observe(srv.poolObserver)
+ srv.pool.Listen(srv.poolListener)
srv.started = true
srv.throw(EventServerStart, srv)
@@ -169,9 +169,9 @@ func (srv *Server) Pool() Pool {
return srv.pool
}
-// Observe pool events.
-func (srv *Server) poolObserver(event int, ctx interface{}) {
- // bypassing to user specified observer
+// Listen pool events.
+func (srv *Server) poolListener(event int, ctx interface{}) {
+ // bypassing to user specified listener
srv.throw(event, ctx)
if event == EventPoolError {
@@ -192,7 +192,7 @@ func (srv *Server) poolObserver(event int, ctx interface{}) {
// throw invokes event handler if any.
func (srv *Server) throw(event int, ctx interface{}) {
- if srv.observer != nil {
- srv.observer(event, ctx)
+ if srv.listener != nil {
+ srv.listener(event, ctx)
}
}