-
Notifications
You must be signed in to change notification settings - Fork 42
/
di.go
22 lines (19 loc) 路 907 Bytes
/
di.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package servicediscovery
import (
"github.com/yoyofx/yoyogo/abstractions/servicediscovery"
grpconn "github.com/yoyofx/yoyogo/grpc/conn"
"github.com/yoyofx/yoyogo/pkg/httpclient"
"github.com/yoyofxteam/dependencyinjection"
)
func UseGeneralServiceDiscovery(serviceCollection *dependencyinjection.ServiceCollection) {
// service discovery Client
serviceCollection.AddSingletonByImplements(NewClient, new(servicediscovery.IServiceDiscoveryClient))
// registration for Cache and options
serviceCollection.AddSingletonByImplements(servicediscovery.NewCache, new(servicediscovery.Cache))
// selector for service discovery
serviceCollection.AddSingletonByImplements(servicediscovery.NewSelector, new(servicediscovery.ISelector))
// http client factory
serviceCollection.AddSingleton(httpclient.NewDiscoveryClientFactory)
// grpc client factory
serviceCollection.AddSingleton(grpconn.NewFactory)
}