-
Notifications
You must be signed in to change notification settings - Fork 8
/
service.go
38 lines (31 loc) · 904 Bytes
/
service.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package domain
import (
"context"
"fmt"
"net/http"
"github.com/delving/hub3/ikuzo/logger"
"github.com/go-chi/chi"
)
var ErrServiceNotEnabled = fmt.Errorf("service not enabled for this organization")
// Service defines minimal API service of an ikuzo.Service
type Service interface {
// Metrics() interface{}
http.Handler
Router
SetServiceBuilder(b *ServiceBuilder)
Shutdown
}
// Shutdown must be implement by each service that uses background services or connections.
type Shutdown interface {
Shutdown(ctx context.Context) error
}
// Router implements a callback to register routes to a chi.Router
// If pattern is non-empty this mount point will be used, instead of the
// default specified by the domain.Service implementation
type Router interface {
Routes(pattern string, router chi.Router)
}
type ServiceBuilder struct {
Logger *logger.CustomLogger
Orgs OrgConfigRetriever
}