-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
serviceHandler.go
46 lines (36 loc) · 1.17 KB
/
serviceHandler.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
39
40
41
42
43
44
45
46
package service
import (
"github.com/plgd-dev/go-coap/v2/tcp"
coapgwService "github.com/plgd-dev/hub/v2/coap-gateway/service"
)
type ServiceHandlerConfig struct {
coapConn *tcp.ClientConn
}
func (s *ServiceHandlerConfig) GetCoapConnection() *tcp.ClientConn {
return s.coapConn
}
type Option interface {
Apply(o *ServiceHandlerConfig)
}
type CoapConnectionOpt struct {
coapConn *tcp.ClientConn
}
func (o CoapConnectionOpt) Apply(opts *ServiceHandlerConfig) {
opts.coapConn = o.coapConn
}
func WithCoapConnectionOpt(c *tcp.ClientConn) CoapConnectionOpt {
return CoapConnectionOpt{
coapConn: c,
}
}
type MakeServiceHandler = func(service *Service, opts ...Option) ServiceHandler
type VerifyServiceHandler = func(ServiceHandler)
type ServiceHandler interface {
SignUp(req coapgwService.CoapSignUpRequest) (coapgwService.CoapSignUpResponse, error)
SignOff() error
SignIn(req coapgwService.CoapSignInReq) (coapgwService.CoapSignInResp, error)
SignOut(req coapgwService.CoapSignInReq) error
PublishResources(req PublishRequest) error
UnpublishResources(req UnpublishRequest) error
RefreshToken(req coapgwService.CoapRefreshTokenReq) (coapgwService.CoapRefreshTokenResp, error)
}