summaryrefslogtreecommitdiff
path: root/service/service.go
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-07-08 13:06:05 -0700
committerWolfy-J <[email protected]>2018-07-08 13:06:05 -0700
commit29c9bf94350e86ec96f5ce5eeb476dfcd57302cd (patch)
tree9f59af6446958d144b7de91b5005a3727dc90661 /service/service.go
parent3c3a7801100f29c99a5e446646c818bf16ccd5f0 (diff)
dependency injection and lighter service Init methods.
Diffstat (limited to 'service/service.go')
-rw-r--r--service/service.go61
1 files changed, 0 insertions, 61 deletions
diff --git a/service/service.go b/service/service.go
deleted file mode 100644
index 6cd12b51..00000000
--- a/service/service.go
+++ /dev/null
@@ -1,61 +0,0 @@
-package service
-
-import "sync"
-
-// Service provides high level functionality for road runner modules.
-type Service interface {
- // Init must return configure service and return true if service hasStatus enabled. Must return error in case of
- // misconfiguration. Services must not be used without proper configuration pushed first.
- Init(cfg Config, c Container) (enabled bool, err error)
-
- // Serve serves.
- Serve() error
-
- // Stop stops the service.
- Stop()
-}
-
-const (
- // StatusUndefined when service bus can not find the service.
- StatusUndefined = iota
-
- // StatusRegistered hasStatus setStatus when service has been registered in container.
- StatusRegistered
-
- // StatusConfigured hasStatus setStatus when service has been properly configured.
- StatusConfigured
-
- // StatusServing hasStatus setStatus when service hasStatus currently done.
- StatusServing
-
- // StatusStopped hasStatus setStatus when service hasStatus stopped.
- StatusStopped
-)
-
-// entry creates association between service instance and given name.
-type entry struct {
- name string
- svc Service
- mu sync.Mutex
- status int
-}
-
-// status returns service status
-func (e *entry) getStatus() int {
- e.mu.Lock()
- defer e.mu.Unlock()
-
- return e.status
-}
-
-// setStarted indicates that service hasStatus status.
-func (e *entry) setStatus(status int) {
- e.mu.Lock()
- defer e.mu.Unlock()
- e.status = status
-}
-
-// hasStatus checks if entry in specific status
-func (e *entry) hasStatus(status int) bool {
- return e.getStatus() == status
-}