forked from st3v/go-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkubernetes.go
37 lines (30 loc) · 933 Bytes
/
kubernetes.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
// Package kubernetes lets you initialise a web service using the k8s registry plugin
package kubernetes
import (
"github.com/micro/go-micro"
"github.com/micro/go-micro/service/grpc"
"github.com/micro/go-micro/web"
"github.com/micro/go-plugins/registry/kubernetes"
// static selector offloads load balancing to k8s services
// enable with MICRO_SELECTOR=static or --selector=static
// requires user to create k8s services
"github.com/micro/go-plugins/client/selector/static"
)
// NewService returns a web service for kubernetes
func NewService(opts ...web.Option) web.Service {
// setup
k := kubernetes.NewRegistry()
st := static.NewSelector()
// create new service
service := grpc.NewService(
micro.Registry(k),
micro.Selector(st),
)
// prepend option
options := []web.Option{
web.MicroService(service),
}
options = append(options, opts...)
// return new service
return web.NewService(options...)
}