2018-05-22 06:16:57 -05:00
|
|
|
package sharding
|
|
|
|
|
2018-05-22 11:33:46 -04:00
|
|
|
// Service defines items that can be registered into a sharding node's serviceFuncs.
|
2018-05-22 06:16:57 -05:00
|
|
|
//
|
2018-05-22 11:33:46 -04:00
|
|
|
// life-cycle management is delegated to the sharding node. The service is allowed to
|
2018-05-22 06:16:57 -05:00
|
|
|
// initialize itself upon creation, but no goroutines should be spun up outside of the
|
|
|
|
// Start method.
|
|
|
|
type Service interface {
|
|
|
|
// Start is called after all services have been constructed and the networking
|
|
|
|
// layer was also initialized to spawn any goroutines required by the service.
|
|
|
|
Start() error
|
|
|
|
|
|
|
|
// Stop terminates all goroutines belonging to the service, blocking until they
|
|
|
|
// are all terminated.
|
|
|
|
Stop() error
|
|
|
|
}
|
2018-05-22 06:53:15 -05:00
|
|
|
|
2018-05-22 07:47:35 -05:00
|
|
|
// ServiceConstructor defines the callback passed in when registering a service
|
|
|
|
// to a sharding node.
|
2018-05-22 16:12:02 -06:00
|
|
|
type ServiceConstructor func() (Service, error)
|