service and client implements last grpc server and client interfaces, improved errors, add signals handling

This commit is contained in:
2020-11-27 14:00:45 +01:00
parent c1d38dfbd0
commit a6696b1d39
13 changed files with 839 additions and 689 deletions

View File

@ -3,13 +3,17 @@ package client
import (
"crypto/tls"
"google.golang.org/grpc"
"gitlab.bertha.cloud/partitio/lab/grpc/registry"
)
type Options interface {
Name() string
Version() string
Registry() registry.Registry
TLSConfig() *tls.Config
DialOptions() []grpc.DialOption
}
type Option func(*options)
@ -20,6 +24,12 @@ func WithRegistry(registry registry.Registry) Option {
}
}
func WithName(name string) Option {
return func(o *options) {
o.name = name
}
}
func WithVersion(version string) Option {
return func(o *options) {
o.version = version
@ -38,11 +48,23 @@ func WithSecure(s bool) Option {
}
}
func WithDialOptions(opts ...grpc.DialOption) Option {
return func(o *options) {
o.dialOptions = opts
}
}
type options struct {
registry registry.Registry
version string
tlsConfig *tls.Config
secure bool
registry registry.Registry
name string
version string
tlsConfig *tls.Config
secure bool
dialOptions []grpc.DialOption
}
func (o *options) Name() string {
return o.name
}
func (o *options) Version() string {
@ -61,3 +83,6 @@ func (o *options) Secure() bool {
return o.secure
}
func (o *options) DialOptions() []grpc.DialOption {
return o.dialOptions
}