forked from krakend/krakend-ce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sd.go
29 lines (23 loc) · 937 Bytes
/
sd.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
package krakend
import (
"context"
"fmt"
consul "github.com/devopsfaith/krakend-consul"
"github.com/luraproject/lura/config"
"github.com/luraproject/lura/logging"
"github.com/luraproject/lura/sd/dnssrv"
)
// RegisterSubscriberFactories registers all the available sd adaptors
func RegisterSubscriberFactories(ctx context.Context, cfg config.ServiceConfig, logger logging.Logger) func(n string, p int) {
// register the dns service discovery
dnssrv.Register()
return func(name string, port int) {
if err := consul.Register(ctx, cfg.ExtraConfig, port, name, logger); err != nil {
logger.Error(fmt.Sprintf("Couldn't register %s:%d in consul: %s", name, port, err.Error()))
}
}
}
type registerSubscriberFactories struct{}
func (d registerSubscriberFactories) Register(ctx context.Context, cfg config.ServiceConfig, logger logging.Logger) func(n string, p int) {
return RegisterSubscriberFactories(ctx, cfg, logger)
}