mirror of
https://github.com/linka-cloud/grpc.git
synced 2025-06-22 09:12:28 +00:00
service and client implements last grpc server and client interfaces, improved errors, add signals handling
This commit is contained in:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user