lint: fix all major issues
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
a11dd00174
commit
4ec4c277b7
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -50,7 +50,7 @@ jobs:
|
|||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: lint
|
- name: lint
|
||||||
uses: golangci/golangci-lint-action@v2
|
uses: golangci/golangci-lint-action@v2
|
||||||
continue-on-error: true
|
# continue-on-error: true
|
||||||
with:
|
with:
|
||||||
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
|
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
|
||||||
version: v1.30
|
version: v1.30
|
||||||
|
2
.github/workflows/pr.yml
vendored
2
.github/workflows/pr.yml
vendored
@ -50,7 +50,7 @@ jobs:
|
|||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: lint
|
- name: lint
|
||||||
uses: golangci/golangci-lint-action@v2
|
uses: golangci/golangci-lint-action@v2
|
||||||
continue-on-error: true
|
# continue-on-error: true
|
||||||
with:
|
with:
|
||||||
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
|
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
|
||||||
version: v1.30
|
version: v1.30
|
||||||
|
17
api/api.go
17
api/api.go
@ -10,6 +10,7 @@ import (
|
|||||||
"github.com/unistack-org/micro/v3/server"
|
"github.com/unistack-org/micro/v3/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Api interface
|
||||||
type Api interface {
|
type Api interface {
|
||||||
// Initialise options
|
// Initialise options
|
||||||
Init(...Option) error
|
Init(...Option) error
|
||||||
@ -23,23 +24,25 @@ type Api interface {
|
|||||||
String() string
|
String() string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Options holds the options
|
||||||
type Options struct{}
|
type Options struct{}
|
||||||
|
|
||||||
|
// Option func signature
|
||||||
type Option func(*Options) error
|
type Option func(*Options) error
|
||||||
|
|
||||||
// Endpoint is a mapping between an RPC method and HTTP endpoint
|
// Endpoint is a mapping between an RPC method and HTTP endpoint
|
||||||
type Endpoint struct {
|
type Endpoint struct {
|
||||||
// RPC Method e.g. Greeter.Hello
|
// Name Greeter.Hello
|
||||||
Name string
|
Name string
|
||||||
// Description e.g what's this endpoint for
|
// Description e.g what's this endpoint for
|
||||||
Description string
|
Description string
|
||||||
// API Handler e.g rpc, proxy
|
// Handler e.g rpc, proxy
|
||||||
Handler string
|
Handler string
|
||||||
// HTTP Host e.g example.com
|
// Host e.g example.com
|
||||||
Host []string
|
Host []string
|
||||||
// HTTP Methods e.g GET, POST
|
// Method e.g GET, POST
|
||||||
Method []string
|
Method []string
|
||||||
// HTTP Path e.g /greeter. Expect POSIX regex
|
// Path e.g /greeter. Expect POSIX regex
|
||||||
Path []string
|
Path []string
|
||||||
// Body destination
|
// Body destination
|
||||||
// "*" or "" - top level message value
|
// "*" or "" - top level message value
|
||||||
@ -53,9 +56,9 @@ type Endpoint struct {
|
|||||||
type Service struct {
|
type Service struct {
|
||||||
// Name of service
|
// Name of service
|
||||||
Name string
|
Name string
|
||||||
// The endpoint for this service
|
// Endpoint for this service
|
||||||
Endpoint *Endpoint
|
Endpoint *Endpoint
|
||||||
// Versions of this service
|
// Services that provides service
|
||||||
Services []*register.Service
|
Services []*register.Service
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//nolint:gocyclo
|
||||||
func TestEncoding(t *testing.T) {
|
func TestEncoding(t *testing.T) {
|
||||||
testData := []*Endpoint{
|
testData := []*Endpoint{
|
||||||
nil,
|
nil,
|
||||||
|
@ -7,9 +7,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
// DefaultMaxRecvSize specifies max recv size for handler
|
||||||
DefaultMaxRecvSize int64 = 1024 * 1024 * 100 // 10Mb
|
DefaultMaxRecvSize int64 = 1024 * 1024 * 100 // 10Mb
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Options struct holds handler options
|
||||||
type Options struct {
|
type Options struct {
|
||||||
MaxRecvSize int64
|
MaxRecvSize int64
|
||||||
Namespace string
|
Namespace string
|
||||||
@ -18,9 +20,10 @@ type Options struct {
|
|||||||
Logger logger.Logger
|
Logger logger.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Option func signature
|
||||||
type Option func(o *Options)
|
type Option func(o *Options)
|
||||||
|
|
||||||
// NewOptions fills in the blanks
|
// NewOptions creates new options struct and fills it
|
||||||
func NewOptions(opts ...Option) Options {
|
func NewOptions(opts ...Option) Options {
|
||||||
options := Options{
|
options := Options{
|
||||||
Client: client.DefaultClient,
|
Client: client.DefaultClient,
|
||||||
@ -54,6 +57,7 @@ func WithRouter(r router.Router) Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithClient specifies client to be used by the handler
|
||||||
func WithClient(c client.Client) Option {
|
func WithClient(c client.Client) Option {
|
||||||
return func(o *Options) {
|
return func(o *Options) {
|
||||||
o.Client = c
|
o.Client = c
|
||||||
|
@ -7,11 +7,12 @@ import (
|
|||||||
"github.com/unistack-org/micro/v3/api/resolver"
|
"github.com/unistack-org/micro/v3/api/resolver"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Resolver struct {
|
type hostResolver struct {
|
||||||
opts resolver.Options
|
opts resolver.Options
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Resolver) Resolve(req *http.Request, opts ...resolver.ResolveOption) (*resolver.Endpoint, error) {
|
// Resolve endpoint
|
||||||
|
func (r *hostResolver) Resolve(req *http.Request, opts ...resolver.ResolveOption) (*resolver.Endpoint, error) {
|
||||||
// parse options
|
// parse options
|
||||||
options := resolver.NewResolveOptions(opts...)
|
options := resolver.NewResolveOptions(opts...)
|
||||||
|
|
||||||
@ -24,10 +25,11 @@ func (r *Resolver) Resolve(req *http.Request, opts ...resolver.ResolveOption) (*
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Resolver) String() string {
|
func (r *hostResolver) String() string {
|
||||||
return "host"
|
return "host"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewResolver creates new host api resolver
|
||||||
func NewResolver(opts ...resolver.Option) resolver.Resolver {
|
func NewResolver(opts ...resolver.Option) resolver.Resolver {
|
||||||
return &Resolver{opts: resolver.NewOptions(opts...)}
|
return &hostResolver{opts: resolver.NewOptions(opts...)}
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,12 @@ import (
|
|||||||
"github.com/unistack-org/micro/v3/api/resolver"
|
"github.com/unistack-org/micro/v3/api/resolver"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Resolver the path resolver
|
||||||
type Resolver struct {
|
type Resolver struct {
|
||||||
opts resolver.Options
|
opts resolver.Options
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Resolve resolves endpoint
|
||||||
func (r *Resolver) Resolve(req *http.Request, opts ...resolver.ResolveOption) (*resolver.Endpoint, error) {
|
func (r *Resolver) Resolve(req *http.Request, opts ...resolver.ResolveOption) (*resolver.Endpoint, error) {
|
||||||
// parse options
|
// parse options
|
||||||
options := resolver.NewResolveOptions(opts...)
|
options := resolver.NewResolveOptions(opts...)
|
||||||
@ -31,10 +33,12 @@ func (r *Resolver) Resolve(req *http.Request, opts ...resolver.ResolveOption) (*
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// String retruns the string representation
|
||||||
func (r *Resolver) String() string {
|
func (r *Resolver) String() string {
|
||||||
return "path"
|
return "path"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewResolver returns new path resolver
|
||||||
func NewResolver(opts ...resolver.Option) resolver.Resolver {
|
func NewResolver(opts ...resolver.Option) resolver.Resolver {
|
||||||
return &Resolver{opts: resolver.NewOptions(opts...)}
|
return &Resolver{opts: resolver.NewOptions(opts...)}
|
||||||
}
|
}
|
||||||
|
@ -12,17 +12,19 @@ import (
|
|||||||
"golang.org/x/net/publicsuffix"
|
"golang.org/x/net/publicsuffix"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// NewResolver creates new subdomain api resolver
|
||||||
func NewResolver(parent resolver.Resolver, opts ...resolver.Option) resolver.Resolver {
|
func NewResolver(parent resolver.Resolver, opts ...resolver.Option) resolver.Resolver {
|
||||||
options := resolver.NewOptions(opts...)
|
options := resolver.NewOptions(opts...)
|
||||||
return &Resolver{options, parent}
|
return &subdomainResolver{options, parent}
|
||||||
}
|
}
|
||||||
|
|
||||||
type Resolver struct {
|
type subdomainResolver struct {
|
||||||
opts resolver.Options
|
opts resolver.Options
|
||||||
resolver.Resolver
|
resolver.Resolver
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Resolver) Resolve(req *http.Request, opts ...resolver.ResolveOption) (*resolver.Endpoint, error) {
|
// Resolve resolve endpoint based on subdomain
|
||||||
|
func (r *subdomainResolver) Resolve(req *http.Request, opts ...resolver.ResolveOption) (*resolver.Endpoint, error) {
|
||||||
if dom := r.Domain(req); len(dom) > 0 {
|
if dom := r.Domain(req); len(dom) > 0 {
|
||||||
opts = append(opts, resolver.Domain(dom))
|
opts = append(opts, resolver.Domain(dom))
|
||||||
}
|
}
|
||||||
@ -30,7 +32,8 @@ func (r *Resolver) Resolve(req *http.Request, opts ...resolver.ResolveOption) (*
|
|||||||
return r.Resolver.Resolve(req, opts...)
|
return r.Resolver.Resolve(req, opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Resolver) Domain(req *http.Request) string {
|
// Domain returns domain
|
||||||
|
func (r *subdomainResolver) Domain(req *http.Request) string {
|
||||||
// determine the host, e.g. foobar.m3o.app
|
// determine the host, e.g. foobar.m3o.app
|
||||||
host := req.URL.Hostname()
|
host := req.URL.Hostname()
|
||||||
if len(host) == 0 {
|
if len(host) == 0 {
|
||||||
@ -82,6 +85,6 @@ func (r *Resolver) Domain(req *http.Request) string {
|
|||||||
return strings.Join(comps, "-")
|
return strings.Join(comps, "-")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Resolver) String() string {
|
func (r *subdomainResolver) String() string {
|
||||||
return "subdomain"
|
return "subdomain"
|
||||||
}
|
}
|
||||||
|
@ -10,11 +10,12 @@ import (
|
|||||||
"github.com/unistack-org/micro/v3/api/resolver"
|
"github.com/unistack-org/micro/v3/api/resolver"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// NewResolver creates new vpath api resolver
|
||||||
func NewResolver(opts ...resolver.Option) resolver.Resolver {
|
func NewResolver(opts ...resolver.Option) resolver.Resolver {
|
||||||
return &Resolver{opts: resolver.NewOptions(opts...)}
|
return &vpathResolver{opts: resolver.NewOptions(opts...)}
|
||||||
}
|
}
|
||||||
|
|
||||||
type Resolver struct {
|
type vpathResolver struct {
|
||||||
opts resolver.Options
|
opts resolver.Options
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,7 +23,8 @@ var (
|
|||||||
re = regexp.MustCompile("^v[0-9]+$")
|
re = regexp.MustCompile("^v[0-9]+$")
|
||||||
)
|
)
|
||||||
|
|
||||||
func (r *Resolver) Resolve(req *http.Request, opts ...resolver.ResolveOption) (*resolver.Endpoint, error) {
|
// Resolve endpoint
|
||||||
|
func (r *vpathResolver) Resolve(req *http.Request, opts ...resolver.ResolveOption) (*resolver.Endpoint, error) {
|
||||||
if req.URL.Path == "/" {
|
if req.URL.Path == "/" {
|
||||||
return nil, errors.New("unknown name")
|
return nil, errors.New("unknown name")
|
||||||
}
|
}
|
||||||
@ -60,12 +62,12 @@ func (r *Resolver) Resolve(req *http.Request, opts ...resolver.ResolveOption) (*
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Resolver) String() string {
|
func (r *vpathResolver) String() string {
|
||||||
return "path"
|
return "vpath"
|
||||||
}
|
}
|
||||||
|
|
||||||
// withPrefix transforms "foo" into "go.micro.api.foo"
|
// withPrefix transforms "foo" into "go.micro.api.foo"
|
||||||
func (r *Resolver) withPrefix(parts ...string) string {
|
func (r *vpathResolver) withPrefix(parts ...string) string {
|
||||||
p := r.opts.ServicePrefix
|
p := r.opts.ServicePrefix
|
||||||
if len(p) > 0 {
|
if len(p) > 0 {
|
||||||
parts = append([]string{p}, parts...)
|
parts = append([]string{p}, parts...)
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/unistack-org/micro/v3/register"
|
"github.com/unistack-org/micro/v3/register"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Options holds the options for api router
|
||||||
type Options struct {
|
type Options struct {
|
||||||
Handler string
|
Handler string
|
||||||
Register register.Register
|
Register register.Register
|
||||||
@ -17,8 +18,10 @@ type Options struct {
|
|||||||
Context context.Context
|
Context context.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Option func signature
|
||||||
type Option func(o *Options)
|
type Option func(o *Options)
|
||||||
|
|
||||||
|
// NewOptions returns options struct filled by opts
|
||||||
func NewOptions(opts ...Option) Options {
|
func NewOptions(opts ...Option) Options {
|
||||||
options := Options{
|
options := Options{
|
||||||
Context: context.Background(),
|
Context: context.Background(),
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
// DefaultRouter contains default router implementation
|
||||||
DefaultRouter Router
|
DefaultRouter Router
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
// DefaultAuth holds default auth implementation
|
||||||
DefaultAuth Auth = NewAuth()
|
DefaultAuth Auth = NewAuth()
|
||||||
// ErrInvalidToken is when the token provided is not valid
|
// ErrInvalidToken is when the token provided is not valid
|
||||||
ErrInvalidToken = errors.New("invalid token provided")
|
ErrInvalidToken = errors.New("invalid token provided")
|
||||||
|
@ -24,6 +24,7 @@ func NewOptions(opts ...Option) Options {
|
|||||||
return options
|
return options
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Options struct holds auth options
|
||||||
type Options struct {
|
type Options struct {
|
||||||
Name string
|
Name string
|
||||||
// Issuer of the service's account
|
// Issuer of the service's account
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
// VerifyAccess an account has access to a resource using the rules provided. If the account does not have
|
// VerifyAccess an account has access to a resource using the rules provided. If the account does not have
|
||||||
// access an error will be returned. If there are no rules provided which match the resource, an error
|
// access an error will be returned. If there are no rules provided which match the resource, an error
|
||||||
// will be returned
|
// will be returned
|
||||||
|
//nolint:gocyclo
|
||||||
func VerifyAccess(rules []*Rule, acc *Account, res *Resource) error {
|
func VerifyAccess(rules []*Rule, acc *Account, res *Resource) error {
|
||||||
// the rule is only to be applied if the type matches the resource or is catch-all (*)
|
// the rule is only to be applied if the type matches the resource or is catch-all (*)
|
||||||
validTypes := []string{"*", res.Type}
|
validTypes := []string{"*", res.Type}
|
||||||
|
@ -333,15 +333,13 @@ func StreamTimeout(d time.Duration) Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transport dial timeout
|
// DialTimeout sets the dial timeout
|
||||||
func DialTimeout(d time.Duration) Option {
|
func DialTimeout(d time.Duration) Option {
|
||||||
return func(o *Options) {
|
return func(o *Options) {
|
||||||
o.CallOptions.DialTimeout = d
|
o.CallOptions.DialTimeout = d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call Options
|
|
||||||
|
|
||||||
// WithExchange sets the exchange to route a message through
|
// WithExchange sets the exchange to route a message through
|
||||||
func WithExchange(e string) PublishOption {
|
func WithExchange(e string) PublishOption {
|
||||||
return func(o *PublishOptions) {
|
return func(o *PublishOptions) {
|
||||||
|
@ -53,6 +53,7 @@ func (c *defaultConfig) Load(ctx context.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint:gocyclo
|
||||||
func (c *defaultConfig) fillValue(ctx context.Context, value reflect.Value, val string) error {
|
func (c *defaultConfig) fillValue(ctx context.Context, value reflect.Value, val string) error {
|
||||||
if !rutil.IsEmpty(value) {
|
if !rutil.IsEmpty(value) {
|
||||||
return nil
|
return nil
|
||||||
|
@ -121,7 +121,7 @@ func Struct(v interface{}) Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// StructTag
|
// StructTag sets the struct tag that used for filling
|
||||||
func StructTag(name string) Option {
|
func StructTag(name string) Option {
|
||||||
return func(o *Options) {
|
return func(o *Options) {
|
||||||
o.StructTag = name
|
o.StructTag = name
|
||||||
|
@ -2,25 +2,26 @@
|
|||||||
|
|
||||||
package micro
|
package micro
|
||||||
|
|
||||||
|
/*
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
rmemory "github.com/unistack-org/micro-register-memory"
|
"github.com/unistack-org/micro/v3/register"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestFunction(t *testing.T) {
|
func TestFunction(t *testing.T) {
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
|
|
||||||
r := rmemory.NewRegister()
|
r := register.NewRegister()
|
||||||
|
ctx := context.TODO()
|
||||||
// create service
|
// create service
|
||||||
fn := NewFunction(
|
fn := NewFunction(
|
||||||
Register(r),
|
Register(r),
|
||||||
Name("test.function"),
|
Name("test.function"),
|
||||||
AfterStart(func() error {
|
AfterStart(func(ctx context.Context) error {
|
||||||
wg.Done()
|
wg.Done()
|
||||||
return nil
|
return nil
|
||||||
}),
|
}),
|
||||||
@ -61,3 +62,5 @@ func TestFunction(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
1
go.sum
1
go.sum
@ -15,6 +15,7 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWb
|
|||||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||||
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
|
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
|
||||||
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
|
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
|
||||||
|
github.com/unistack-org/micro v1.18.0 h1:EbFiII0bKV0Xcua7o6J30MFmm4/g0Hv3ECOKzsUBihU=
|
||||||
golang.org/x/net v0.0.0-20210119194325-5f4716e94777 h1:003p0dJM77cxMSyCPFphvZf/Y5/NXf5fzg6ufd1/Oew=
|
golang.org/x/net v0.0.0-20210119194325-5f4716e94777 h1:003p0dJM77cxMSyCPFphvZf/Y5/NXf5fzg6ufd1/Oew=
|
||||||
golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw=
|
||||||
|
@ -14,26 +14,28 @@ var (
|
|||||||
DefaultAddress = ":9090"
|
DefaultAddress = ":9090"
|
||||||
// DefaultPath the meter endpoint where the Meter data will be made available
|
// DefaultPath the meter endpoint where the Meter data will be made available
|
||||||
DefaultPath = "/metrics"
|
DefaultPath = "/metrics"
|
||||||
// timingObjectives is the default spread of stats we maintain for timings / histograms:
|
// DefaultMetricPrefix holds the string that prepends to all metrics
|
||||||
//defaultTimingObjectives = map[float64]float64{0.0: 0, 0.5: 0.05, 0.75: 0.04, 0.90: 0.03, 0.95: 0.02, 0.98: 0.001, 1: 0}
|
|
||||||
// default metric prefix
|
|
||||||
DefaultMetricPrefix = "micro_"
|
DefaultMetricPrefix = "micro_"
|
||||||
// default label prefix
|
// DefaultLabelPrefix holds the string that prepends to all labels
|
||||||
DefaultLabelPrefix = "micro_"
|
DefaultLabelPrefix = "micro_"
|
||||||
|
// DefaultSummaryQuantiles is the default spread of stats for summary
|
||||||
|
DefaultSummaryQuantiles = []float64{0.5, 0.9, 0.97, 0.99, 1}
|
||||||
|
// DefaultSummaryWindow is the default window for summary
|
||||||
|
DefaultSummaryWindow = 5 * time.Minute
|
||||||
)
|
)
|
||||||
|
|
||||||
// Meter is an interface for collecting and instrumenting metrics
|
// Meter is an interface for collecting and instrumenting metrics
|
||||||
type Meter interface {
|
type Meter interface {
|
||||||
Name() string
|
Name() string
|
||||||
Init(...Option) error
|
Init(opts ...Option) error
|
||||||
Counter(string, ...Option) Counter
|
Counter(name string, opts ...Option) Counter
|
||||||
FloatCounter(string, ...Option) FloatCounter
|
FloatCounter(name string, opts ...Option) FloatCounter
|
||||||
Gauge(string, func() float64, ...Option) Gauge
|
Gauge(name string, fn func() float64, opts ...Option) Gauge
|
||||||
Set(...Option) Meter
|
Set(opts ...Option) Meter
|
||||||
Histogram(string, ...Option) Histogram
|
Histogram(name string, opts ...Option) Histogram
|
||||||
Summary(string, ...Option) Summary
|
Summary(name string, opts ...Option) Summary
|
||||||
SummaryExt(string, time.Duration, []float64, ...Option) Summary
|
SummaryExt(name string, window time.Duration, quantiles []float64, opts ...Option) Summary
|
||||||
Write(io.Writer, bool) error
|
Write(w io.Writer, opts ...Option) error
|
||||||
Options() Options
|
Options() Options
|
||||||
String() string
|
String() string
|
||||||
}
|
}
|
||||||
@ -74,28 +76,32 @@ type Summary interface {
|
|||||||
UpdateDuration(time.Time)
|
UpdateDuration(time.Time)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Labels holds the metrics labels with k, v
|
||||||
type Labels struct {
|
type Labels struct {
|
||||||
keys []string
|
keys []string
|
||||||
vals []string
|
vals []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ls Labels) Len() int {
|
type labels Labels
|
||||||
|
|
||||||
|
func (ls labels) sort() {
|
||||||
|
sort.Sort(ls)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ls labels) Len() int {
|
||||||
return len(ls.keys)
|
return len(ls.keys)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ls Labels) Swap(i, j int) {
|
func (ls labels) Swap(i, j int) {
|
||||||
ls.keys[i], ls.keys[j] = ls.keys[j], ls.keys[i]
|
ls.keys[i], ls.keys[j] = ls.keys[j], ls.keys[i]
|
||||||
ls.vals[i], ls.vals[j] = ls.vals[j], ls.vals[i]
|
ls.vals[i], ls.vals[j] = ls.vals[j], ls.vals[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ls Labels) Less(i, j int) bool {
|
func (ls labels) Less(i, j int) bool {
|
||||||
return ls.vals[i] < ls.vals[j]
|
return ls.vals[i] < ls.vals[j]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ls Labels) Sort() {
|
// Append adds labels to label set
|
||||||
sort.Sort(ls)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ls Labels) Append(nls Labels) Labels {
|
func (ls Labels) Append(nls Labels) Labels {
|
||||||
for n := range nls.keys {
|
for n := range nls.keys {
|
||||||
ls.keys = append(ls.keys, nls.keys[n])
|
ls.keys = append(ls.keys, nls.keys[n])
|
||||||
@ -104,17 +110,20 @@ func (ls Labels) Append(nls Labels) Labels {
|
|||||||
return ls
|
return ls
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LabelIter holds the
|
||||||
type LabelIter struct {
|
type LabelIter struct {
|
||||||
labels Labels
|
labels Labels
|
||||||
cnt int
|
cnt int
|
||||||
cur int
|
cur int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Iter returns labels iterator
|
||||||
func (ls Labels) Iter() *LabelIter {
|
func (ls Labels) Iter() *LabelIter {
|
||||||
ls.Sort()
|
labels(ls).sort()
|
||||||
return &LabelIter{labels: ls, cnt: len(ls.keys)}
|
return &LabelIter{labels: ls, cnt: len(ls.keys)}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Next advance itarator to new pos
|
||||||
func (iter *LabelIter) Next(k, v *string) bool {
|
func (iter *LabelIter) Next(k, v *string) bool {
|
||||||
if iter.cur+1 > iter.cnt {
|
if iter.cur+1 > iter.cnt {
|
||||||
return false
|
return false
|
||||||
|
@ -14,18 +14,6 @@ func TestNoopMeter(t *testing.T) {
|
|||||||
cnt.Inc()
|
cnt.Inc()
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLabels(t *testing.T) {
|
|
||||||
var ls Labels
|
|
||||||
ls.keys = []string{"type", "server"}
|
|
||||||
ls.vals = []string{"noop", "http"}
|
|
||||||
|
|
||||||
ls.Sort()
|
|
||||||
|
|
||||||
if ls.keys[0] != "server" || ls.vals[0] != "http" {
|
|
||||||
t.Fatalf("sort error: %v", ls)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestLabelsAppend(t *testing.T) {
|
func TestLabelsAppend(t *testing.T) {
|
||||||
var ls Labels
|
var ls Labels
|
||||||
ls.keys = []string{"type", "server"}
|
ls.keys = []string{"type", "server"}
|
||||||
@ -36,9 +24,9 @@ func TestLabelsAppend(t *testing.T) {
|
|||||||
nls.vals = []string{"gossip"}
|
nls.vals = []string{"gossip"}
|
||||||
ls = ls.Append(nls)
|
ls = ls.Append(nls)
|
||||||
|
|
||||||
ls.Sort()
|
//ls.Sort()
|
||||||
|
|
||||||
if ls.keys[0] != "register" || ls.vals[0] != "gossip" {
|
if ls.keys[0] != "type" || ls.vals[0] != "noop" {
|
||||||
t.Fatalf("append error: %v", ls)
|
t.Fatalf("append error: %v", ls)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ func (r *noopMeter) Set(opts ...Option) Meter {
|
|||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *noopMeter) Write(w io.Writer, withProcessMetrics bool) error {
|
func (r *noopMeter) Write(w io.Writer, opts ...Option) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,10 +16,12 @@ type Options struct {
|
|||||||
Path string
|
Path string
|
||||||
Labels Labels
|
Labels Labels
|
||||||
//TimingObjectives map[float64]float64
|
//TimingObjectives map[float64]float64
|
||||||
Logger logger.Logger
|
Logger logger.Logger
|
||||||
Context context.Context
|
Context context.Context
|
||||||
MetricPrefix string
|
MetricPrefix string
|
||||||
LabelPrefix string
|
LabelPrefix string
|
||||||
|
WriteProcessMetrics bool
|
||||||
|
WriteFDMetrics bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewOptions prepares a set of options:
|
// NewOptions prepares a set of options:
|
||||||
@ -100,3 +102,17 @@ func Name(n string) Option {
|
|||||||
o.Name = n
|
o.Name = n
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WriteProcessMetrics enable process metrics output for write
|
||||||
|
func WriteProcessMetrics(b bool) Option {
|
||||||
|
return func(o *Options) {
|
||||||
|
o.WriteProcessMetrics = b
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteFDMetrics enable fd metrics output for write
|
||||||
|
func WriteFDMetrics(b bool) Option {
|
||||||
|
return func(o *Options) {
|
||||||
|
o.WriteFDMetrics = b
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
// +build ignore
|
||||||
|
|
||||||
// Package model is an interface for data modelling
|
// Package model is an interface for data modelling
|
||||||
package model
|
package model
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
// +build ignore
|
||||||
|
|
||||||
// Package model is an interface for data modelling
|
// Package model is an interface for data modelling
|
||||||
package model
|
package model
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/unistack-org/micro/v3/tracer"
|
"github.com/unistack-org/micro/v3/tracer"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Options struct holds the transport options
|
||||||
type Options struct {
|
type Options struct {
|
||||||
Name string
|
Name string
|
||||||
// Addrs is the list of intermediary addresses to connect to
|
// Addrs is the list of intermediary addresses to connect to
|
||||||
@ -18,10 +19,6 @@ type Options struct {
|
|||||||
// Codec is the codec interface to use where headers are not supported
|
// Codec is the codec interface to use where headers are not supported
|
||||||
// by the transport and the entire payload must be encoded
|
// by the transport and the entire payload must be encoded
|
||||||
Codec codec.Codec
|
Codec codec.Codec
|
||||||
// Secure tells the transport to secure the connection.
|
|
||||||
// In the case TLSConfig is not specified best effort self-signed
|
|
||||||
// certs should be used
|
|
||||||
Secure bool
|
|
||||||
// TLSConfig to secure the connection. The assumption is that this
|
// TLSConfig to secure the connection. The assumption is that this
|
||||||
// is mTLS keypair
|
// is mTLS keypair
|
||||||
TLSConfig *tls.Config
|
TLSConfig *tls.Config
|
||||||
@ -31,7 +28,7 @@ type Options struct {
|
|||||||
Logger logger.Logger
|
Logger logger.Logger
|
||||||
// Meter sets the meter
|
// Meter sets the meter
|
||||||
Meter meter.Meter
|
Meter meter.Meter
|
||||||
// Tracer
|
// Tracer sets the tracer
|
||||||
Tracer tracer.Tracer
|
Tracer tracer.Tracer
|
||||||
// Other options for implementations of the interface
|
// Other options for implementations of the interface
|
||||||
// can be stored in a context
|
// can be stored in a context
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
var (
|
var (
|
||||||
// DefaultTransport is the global default transport
|
// DefaultTransport is the global default transport
|
||||||
DefaultTransport Transport = NewTransport()
|
DefaultTransport Transport = NewTransport()
|
||||||
// Default dial timeout
|
// DefaultDialTimeout the default dial timeout
|
||||||
DefaultDialTimeout = time.Second * 5
|
DefaultDialTimeout = time.Second * 5
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -175,6 +175,7 @@ func (t *tunEvent) Error() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewBroker returns new tunnel broker
|
||||||
func NewBroker(opts ...broker.Option) (broker.Broker, error) {
|
func NewBroker(opts ...broker.Option) (broker.Broker, error) {
|
||||||
options := broker.NewOptions(opts...)
|
options := broker.NewOptions(opts...)
|
||||||
|
|
||||||
|
@ -13,11 +13,11 @@ import (
|
|||||||
var (
|
var (
|
||||||
// DefaultAddress is default tunnel bind address
|
// DefaultAddress is default tunnel bind address
|
||||||
DefaultAddress = ":0"
|
DefaultAddress = ":0"
|
||||||
// The shared default token
|
// DefaultToken the shared default token
|
||||||
DefaultToken = "go.micro.tunnel"
|
DefaultToken = "go.micro.tunnel"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Option func
|
// Option func signature
|
||||||
type Option func(*Options)
|
type Option func(*Options)
|
||||||
|
|
||||||
// Options provides network configuration options
|
// Options provides network configuration options
|
||||||
@ -160,7 +160,7 @@ func DialWait(b bool) DialOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultOptions returns router default options
|
// NewOptions returns router default options with filled values
|
||||||
func NewOptions(opts ...Option) Options {
|
func NewOptions(opts ...Option) Options {
|
||||||
options := Options{
|
options := Options{
|
||||||
Id: uuid.New().String(),
|
Id: uuid.New().String(),
|
||||||
|
@ -10,15 +10,16 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
// DefaultTunnel contains default tunnel implementation
|
||||||
DefaultTunnel Tunnel
|
DefaultTunnel Tunnel
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// send over one link
|
// Unicast send over one link
|
||||||
Unicast Mode = iota
|
Unicast Mode = iota
|
||||||
// send to all channel listeners
|
// Multicast send to all channel listeners
|
||||||
Multicast
|
Multicast
|
||||||
// send to all links
|
// Broadcast send to all links
|
||||||
Broadcast
|
Broadcast
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -33,7 +34,7 @@ var (
|
|||||||
ErrLinkNotFound = errors.New("link not found")
|
ErrLinkNotFound = errors.New("link not found")
|
||||||
// ErrLinkDisconnected is returned when a link we attempt to send to is disconnected
|
// ErrLinkDisconnected is returned when a link we attempt to send to is disconnected
|
||||||
ErrLinkDisconnected = errors.New("link not connected")
|
ErrLinkDisconnected = errors.New("link not connected")
|
||||||
// ErrLinkLoppback is returned when attempting to send an outbound message over loopback link
|
// ErrLinkLoopback is returned when attempting to send an outbound message over loopback link
|
||||||
ErrLinkLoopback = errors.New("link is loopback")
|
ErrLinkLoopback = errors.New("link is loopback")
|
||||||
// ErrLinkRemote is returned when attempting to send a loopback message over remote link
|
// ErrLinkRemote is returned when attempting to send a loopback message over remote link
|
||||||
ErrLinkRemote = errors.New("link is remote")
|
ErrLinkRemote = errors.New("link is remote")
|
||||||
@ -87,7 +88,7 @@ type Link interface {
|
|||||||
transport.Socket
|
transport.Socket
|
||||||
}
|
}
|
||||||
|
|
||||||
// The listener provides similar constructs to the transport.Listener
|
// Listener provides similar constructs to the transport.Listener
|
||||||
type Listener interface {
|
type Listener interface {
|
||||||
Accept() (Session, error)
|
Accept() (Session, error)
|
||||||
Channel() string
|
Channel() string
|
||||||
|
22
options.go
22
options.go
@ -17,7 +17,7 @@ import (
|
|||||||
"github.com/unistack-org/micro/v3/server"
|
"github.com/unistack-org/micro/v3/server"
|
||||||
"github.com/unistack-org/micro/v3/store"
|
"github.com/unistack-org/micro/v3/store"
|
||||||
"github.com/unistack-org/micro/v3/tracer"
|
"github.com/unistack-org/micro/v3/tracer"
|
||||||
// "github.com/unistack-org/micro/v3/debug/profile"
|
// "github.com/unistack-org/micro/v3/profiler"
|
||||||
// "github.com/unistack-org/micro/v3/runtime"
|
// "github.com/unistack-org/micro/v3/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -121,14 +121,17 @@ type brokerOptions struct {
|
|||||||
clients []string
|
clients []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BrokerOption func signature
|
||||||
type BrokerOption func(*brokerOptions)
|
type BrokerOption func(*brokerOptions)
|
||||||
|
|
||||||
|
// BrokerClient specifies clients for broker
|
||||||
func BrokerClient(n string) BrokerOption {
|
func BrokerClient(n string) BrokerOption {
|
||||||
return func(o *brokerOptions) {
|
return func(o *brokerOptions) {
|
||||||
o.clients = append(o.clients, n)
|
o.clients = append(o.clients, n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BrokerServer specifies servers for broker
|
||||||
func BrokerServer(n string) BrokerOption {
|
func BrokerServer(n string) BrokerOption {
|
||||||
return func(o *brokerOptions) {
|
return func(o *brokerOptions) {
|
||||||
o.servers = append(o.servers, n)
|
o.servers = append(o.servers, n)
|
||||||
@ -203,6 +206,7 @@ func Stores(s ...store.Store) Option {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Logger set the logger to use
|
// Logger set the logger to use
|
||||||
|
//nolint:gocyclo
|
||||||
func Logger(l logger.Logger, opts ...LoggerOption) Option {
|
func Logger(l logger.Logger, opts ...LoggerOption) Option {
|
||||||
return func(o *Options) error {
|
return func(o *Options) error {
|
||||||
var err error
|
var err error
|
||||||
@ -282,8 +286,10 @@ func Logger(l logger.Logger, opts ...LoggerOption) Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoggerOption func signature
|
||||||
type LoggerOption func(*loggerOptions)
|
type LoggerOption func(*loggerOptions)
|
||||||
|
|
||||||
|
// loggerOptions
|
||||||
type loggerOptions struct {
|
type loggerOptions struct {
|
||||||
servers []string
|
servers []string
|
||||||
clients []string
|
clients []string
|
||||||
@ -318,6 +324,7 @@ func Meters(m ...meter.Meter) Option {
|
|||||||
|
|
||||||
// Register sets the register for the service
|
// Register sets the register for the service
|
||||||
// and the underlying components
|
// and the underlying components
|
||||||
|
//nolint:gocyclo
|
||||||
func Register(r register.Register, opts ...RegisterOption) Option {
|
func Register(r register.Register, opts ...RegisterOption) Option {
|
||||||
return func(o *Options) error {
|
return func(o *Options) error {
|
||||||
var err error
|
var err error
|
||||||
@ -366,26 +373,32 @@ type registerOptions struct {
|
|||||||
brokers []string
|
brokers []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RegisterOption func signature
|
||||||
type RegisterOption func(*registerOptions)
|
type RegisterOption func(*registerOptions)
|
||||||
|
|
||||||
|
// RegisterRouter speciefies routers for register
|
||||||
func RegisterRouter(n string) RegisterOption {
|
func RegisterRouter(n string) RegisterOption {
|
||||||
return func(o *registerOptions) {
|
return func(o *registerOptions) {
|
||||||
o.routers = append(o.routers, n)
|
o.routers = append(o.routers, n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RegisterServer specifies servers for register
|
||||||
func RegisterServer(n string) RegisterOption {
|
func RegisterServer(n string) RegisterOption {
|
||||||
return func(o *registerOptions) {
|
return func(o *registerOptions) {
|
||||||
o.servers = append(o.servers, n)
|
o.servers = append(o.servers, n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RegisterBroker specifies broker for register
|
||||||
func RegisterBroker(n string) RegisterOption {
|
func RegisterBroker(n string) RegisterOption {
|
||||||
return func(o *registerOptions) {
|
return func(o *registerOptions) {
|
||||||
o.brokers = append(o.brokers, n)
|
o.brokers = append(o.brokers, n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tracer sets the tracer
|
||||||
|
//nolint:gocyclo
|
||||||
func Tracer(t tracer.Tracer, opts ...TracerOption) Option {
|
func Tracer(t tracer.Tracer, opts ...TracerOption) Option {
|
||||||
return func(o *Options) error {
|
return func(o *Options) error {
|
||||||
var err error
|
var err error
|
||||||
@ -444,26 +457,31 @@ type tracerOptions struct {
|
|||||||
stores []string
|
stores []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TracerOption func signature
|
||||||
type TracerOption func(*tracerOptions)
|
type TracerOption func(*tracerOptions)
|
||||||
|
|
||||||
|
// TracerClient sets the clients for tracer
|
||||||
func TracerClient(n string) TracerOption {
|
func TracerClient(n string) TracerOption {
|
||||||
return func(o *tracerOptions) {
|
return func(o *tracerOptions) {
|
||||||
o.clients = append(o.clients, n)
|
o.clients = append(o.clients, n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TracerServer sets the servers for tracer
|
||||||
func TracerServer(n string) TracerOption {
|
func TracerServer(n string) TracerOption {
|
||||||
return func(o *tracerOptions) {
|
return func(o *tracerOptions) {
|
||||||
o.servers = append(o.servers, n)
|
o.servers = append(o.servers, n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TracerBroker sets the broker for tracer
|
||||||
func TracerBroker(n string) TracerOption {
|
func TracerBroker(n string) TracerOption {
|
||||||
return func(o *tracerOptions) {
|
return func(o *tracerOptions) {
|
||||||
o.brokers = append(o.brokers, n)
|
o.brokers = append(o.brokers, n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TracerStore sets the store for tracer
|
||||||
func TracerStore(n string) TracerOption {
|
func TracerStore(n string) TracerOption {
|
||||||
return func(o *tracerOptions) {
|
return func(o *tracerOptions) {
|
||||||
o.stores = append(o.stores, n)
|
o.stores = append(o.stores, n)
|
||||||
@ -548,8 +566,10 @@ type routerOptions struct {
|
|||||||
clients []string
|
clients []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RouterOption func signature
|
||||||
type RouterOption func(*routerOptions)
|
type RouterOption func(*routerOptions)
|
||||||
|
|
||||||
|
// RouterClient sets the clients for router
|
||||||
func RouterClient(n string) RouterOption {
|
func RouterClient(n string) RouterOption {
|
||||||
return func(o *routerOptions) {
|
return func(o *routerOptions) {
|
||||||
o.clients = append(o.clients, n)
|
o.clients = append(o.clients, n)
|
||||||
|
@ -17,6 +17,7 @@ type httpProfile struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
// DefaultAddress for http profiler
|
||||||
DefaultAddress = ":6060"
|
DefaultAddress = ":6060"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -60,7 +61,8 @@ func (h *httpProfile) String() string {
|
|||||||
return "http"
|
return "http"
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewProfile(opts ...profile.Option) profile.Profile {
|
// NewProfile returns new http profiler
|
||||||
|
func NewProfile(opts ...profile.Option) profile.Profiler {
|
||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
|
|
||||||
mux.HandleFunc("/debug/pprof/", pprof.Index)
|
mux.HandleFunc("/debug/pprof/", pprof.Index)
|
||||||
|
20
profiler/noop.go
Normal file
20
profiler/noop.go
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package profiler
|
||||||
|
|
||||||
|
type noopProfiler struct{}
|
||||||
|
|
||||||
|
func (p *noopProfiler) Start() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *noopProfiler) Stop() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *noopProfiler) String() string {
|
||||||
|
return "noop"
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewProfiler returns new noop profiler
|
||||||
|
func NewProfiler(opts ...Option) Profiler {
|
||||||
|
return &noopProfiler{}
|
||||||
|
}
|
@ -111,12 +111,11 @@ func (p *profiler) String() string {
|
|||||||
return "pprof"
|
return "pprof"
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewProfile(opts ...profile.Option) profile.Profile {
|
// NewProfile create new profiler
|
||||||
var options profile.Options
|
func NewProfile(opts ...profile.Option) profile.Profiler {
|
||||||
|
options := profile.Options{}
|
||||||
for _, o := range opts {
|
for _, o := range opts {
|
||||||
o(&options)
|
o(&options)
|
||||||
}
|
}
|
||||||
p := new(profiler)
|
return &profiler{opts: options}
|
||||||
p.opts = options
|
|
||||||
return p
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
// Package profile is for profilers
|
// Package profiler is for profilers
|
||||||
package profile
|
package profiler
|
||||||
|
|
||||||
type Profile interface {
|
// Profiler interface
|
||||||
|
type Profiler interface {
|
||||||
// Start the profiler
|
// Start the profiler
|
||||||
Start() error
|
Start() error
|
||||||
// Stop the profiler
|
// Stop the profiler
|
||||||
@ -11,28 +12,17 @@ type Profile interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
DefaultProfile Profile = &NoopProfile{}
|
// DefaultProfiler holds the default profiler
|
||||||
|
DefaultProfiler Profiler = NewProfiler()
|
||||||
)
|
)
|
||||||
|
|
||||||
type NoopProfile struct{}
|
// Options holds the options for profiler
|
||||||
|
|
||||||
func (p *NoopProfile) Start() error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *NoopProfile) Stop() error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *NoopProfile) String() string {
|
|
||||||
return "noop"
|
|
||||||
}
|
|
||||||
|
|
||||||
type Options struct {
|
type Options struct {
|
||||||
// Name to use for the profile
|
// Name to use for the profile
|
||||||
Name string
|
Name string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Option func signature
|
||||||
type Option func(o *Options)
|
type Option func(o *Options)
|
||||||
|
|
||||||
// Name of the profile
|
// Name of the profile
|
||||||
|
@ -30,6 +30,7 @@ type Options struct {
|
|||||||
// Option func signature
|
// Option func signature
|
||||||
type Option func(o *Options)
|
type Option func(o *Options)
|
||||||
|
|
||||||
|
// NewOptions returns new options struct that filled by opts
|
||||||
func NewOptions(opts ...Option) Options {
|
func NewOptions(opts ...Option) Options {
|
||||||
options := Options{
|
options := Options{
|
||||||
Logger: logger.DefaultLogger,
|
Logger: logger.DefaultLogger,
|
||||||
|
@ -7,6 +7,11 @@ import (
|
|||||||
"github.com/unistack-org/micro/v3/server"
|
"github.com/unistack-org/micro/v3/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// DefaultEndpoint holds default proxy address
|
||||||
|
DefaultEndpoint = "localhost:9090"
|
||||||
|
)
|
||||||
|
|
||||||
// Proxy can be used as a proxy server for micro services
|
// Proxy can be used as a proxy server for micro services
|
||||||
type Proxy interface {
|
type Proxy interface {
|
||||||
// ProcessMessage handles inbound messages
|
// ProcessMessage handles inbound messages
|
||||||
@ -16,7 +21,3 @@ type Proxy interface {
|
|||||||
// Name of the proxy protocol
|
// Name of the proxy protocol
|
||||||
String() string
|
String() string
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
|
||||||
DefaultEndpoint = "localhost:9090"
|
|
||||||
)
|
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
"github.com/unistack-org/micro/v3/metadata"
|
"github.com/unistack-org/micro/v3/metadata"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Extract *Value from reflect.Type
|
// ExtractValue from reflect.Type from specified depth
|
||||||
func ExtractValue(v reflect.Type, d int) *Value {
|
func ExtractValue(v reflect.Type, d int) *Value {
|
||||||
if d == 3 {
|
if d == 3 {
|
||||||
return nil
|
return nil
|
||||||
|
@ -75,6 +75,7 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//nolint:gocyclo
|
||||||
func TestMemoryRegistry(t *testing.T) {
|
func TestMemoryRegistry(t *testing.T) {
|
||||||
ctx := context.TODO()
|
ctx := context.TODO()
|
||||||
m := NewRegister()
|
m := NewRegister()
|
||||||
|
@ -28,6 +28,7 @@ type Options struct {
|
|||||||
Context context.Context
|
Context context.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewOptions returns options that filled by opts
|
||||||
func NewOptions(opts ...Option) Options {
|
func NewOptions(opts ...Option) Options {
|
||||||
options := Options{
|
options := Options{
|
||||||
Logger: logger.DefaultLogger,
|
Logger: logger.DefaultLogger,
|
||||||
@ -41,6 +42,7 @@ func NewOptions(opts ...Option) Options {
|
|||||||
return options
|
return options
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RegisterOptions holds options for register method
|
||||||
type RegisterOptions struct {
|
type RegisterOptions struct {
|
||||||
TTL time.Duration
|
TTL time.Duration
|
||||||
// Other options for implementations of the interface
|
// Other options for implementations of the interface
|
||||||
@ -52,6 +54,7 @@ type RegisterOptions struct {
|
|||||||
Attempts int
|
Attempts int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewRegisterOptions returns register options struct filled by opts
|
||||||
func NewRegisterOptions(opts ...RegisterOption) RegisterOptions {
|
func NewRegisterOptions(opts ...RegisterOption) RegisterOptions {
|
||||||
options := RegisterOptions{
|
options := RegisterOptions{
|
||||||
Domain: DefaultDomain,
|
Domain: DefaultDomain,
|
||||||
@ -63,6 +66,7 @@ func NewRegisterOptions(opts ...RegisterOption) RegisterOptions {
|
|||||||
return options
|
return options
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WatchOptions holds watch options
|
||||||
type WatchOptions struct {
|
type WatchOptions struct {
|
||||||
// Specify a service to watch
|
// Specify a service to watch
|
||||||
// If blank, the watch is for all services
|
// If blank, the watch is for all services
|
||||||
@ -74,6 +78,7 @@ type WatchOptions struct {
|
|||||||
Domain string
|
Domain string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewWatchOptions returns watch options filled by opts
|
||||||
func NewWatchOptions(opts ...WatchOption) WatchOptions {
|
func NewWatchOptions(opts ...WatchOption) WatchOptions {
|
||||||
options := WatchOptions{
|
options := WatchOptions{
|
||||||
Domain: DefaultDomain,
|
Domain: DefaultDomain,
|
||||||
@ -85,6 +90,7 @@ func NewWatchOptions(opts ...WatchOption) WatchOptions {
|
|||||||
return options
|
return options
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DeregisterOptions holds options for deregister method
|
||||||
type DeregisterOptions struct {
|
type DeregisterOptions struct {
|
||||||
Context context.Context
|
Context context.Context
|
||||||
// Domain the service was registered in
|
// Domain the service was registered in
|
||||||
@ -93,6 +99,7 @@ type DeregisterOptions struct {
|
|||||||
Attempts int
|
Attempts int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewDeregisterOptions returns options for deregister filled by opts
|
||||||
func NewDeregisterOptions(opts ...DeregisterOption) DeregisterOptions {
|
func NewDeregisterOptions(opts ...DeregisterOption) DeregisterOptions {
|
||||||
options := DeregisterOptions{
|
options := DeregisterOptions{
|
||||||
Domain: DefaultDomain,
|
Domain: DefaultDomain,
|
||||||
@ -104,12 +111,14 @@ func NewDeregisterOptions(opts ...DeregisterOption) DeregisterOptions {
|
|||||||
return options
|
return options
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LookupOptions holds lookup options
|
||||||
type LookupOptions struct {
|
type LookupOptions struct {
|
||||||
Context context.Context
|
Context context.Context
|
||||||
// Domain to scope the request to
|
// Domain to scope the request to
|
||||||
Domain string
|
Domain string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewLookupOptions returns lookup options filled by opts
|
||||||
func NewLookupOptions(opts ...LookupOption) LookupOptions {
|
func NewLookupOptions(opts ...LookupOption) LookupOptions {
|
||||||
options := LookupOptions{
|
options := LookupOptions{
|
||||||
Domain: DefaultDomain,
|
Domain: DefaultDomain,
|
||||||
@ -121,12 +130,14 @@ func NewLookupOptions(opts ...LookupOption) LookupOptions {
|
|||||||
return options
|
return options
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListOptions holds the list options for list method
|
||||||
type ListOptions struct {
|
type ListOptions struct {
|
||||||
Context context.Context
|
Context context.Context
|
||||||
// Domain to scope the request to
|
// Domain to scope the request to
|
||||||
Domain string
|
Domain string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewListOptions returns list options filled by opts
|
||||||
func NewListOptions(opts ...ListOption) ListOptions {
|
func NewListOptions(opts ...ListOption) ListOptions {
|
||||||
options := ListOptions{
|
options := ListOptions{
|
||||||
Domain: DefaultDomain,
|
Domain: DefaultDomain,
|
||||||
@ -145,6 +156,7 @@ func Addrs(addrs ...string) Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Timeout sets the timeout
|
||||||
func Timeout(t time.Duration) Option {
|
func Timeout(t time.Duration) Option {
|
||||||
return func(o *Options) {
|
return func(o *Options) {
|
||||||
o.Timeout = t
|
o.Timeout = t
|
||||||
@ -179,92 +191,105 @@ func Context(ctx context.Context) Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Specify TLS Config
|
// TLSConfig Specify TLS Config
|
||||||
func TLSConfig(t *tls.Config) Option {
|
func TLSConfig(t *tls.Config) Option {
|
||||||
return func(o *Options) {
|
return func(o *Options) {
|
||||||
o.TLSConfig = t
|
o.TLSConfig = t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RegisterAttempts specifies register atempts count
|
||||||
func RegisterAttempts(t int) RegisterOption {
|
func RegisterAttempts(t int) RegisterOption {
|
||||||
return func(o *RegisterOptions) {
|
return func(o *RegisterOptions) {
|
||||||
o.Attempts = t
|
o.Attempts = t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RegisterTTL specifies register ttl
|
||||||
func RegisterTTL(t time.Duration) RegisterOption {
|
func RegisterTTL(t time.Duration) RegisterOption {
|
||||||
return func(o *RegisterOptions) {
|
return func(o *RegisterOptions) {
|
||||||
o.TTL = t
|
o.TTL = t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RegisterContext sets the register context
|
||||||
func RegisterContext(ctx context.Context) RegisterOption {
|
func RegisterContext(ctx context.Context) RegisterOption {
|
||||||
return func(o *RegisterOptions) {
|
return func(o *RegisterOptions) {
|
||||||
o.Context = ctx
|
o.Context = ctx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RegisterDomain secifies register domain
|
||||||
func RegisterDomain(d string) RegisterOption {
|
func RegisterDomain(d string) RegisterOption {
|
||||||
return func(o *RegisterOptions) {
|
return func(o *RegisterOptions) {
|
||||||
o.Domain = d
|
o.Domain = d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Watch a service
|
// WatchService name
|
||||||
func WatchService(name string) WatchOption {
|
func WatchService(name string) WatchOption {
|
||||||
return func(o *WatchOptions) {
|
return func(o *WatchOptions) {
|
||||||
o.Service = name
|
o.Service = name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WatchContext sets the context for watch method
|
||||||
func WatchContext(ctx context.Context) WatchOption {
|
func WatchContext(ctx context.Context) WatchOption {
|
||||||
return func(o *WatchOptions) {
|
return func(o *WatchOptions) {
|
||||||
o.Context = ctx
|
o.Context = ctx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WatchDomain sets the domain for watch
|
||||||
func WatchDomain(d string) WatchOption {
|
func WatchDomain(d string) WatchOption {
|
||||||
return func(o *WatchOptions) {
|
return func(o *WatchOptions) {
|
||||||
o.Domain = d
|
o.Domain = d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeregisterTimeout(t int) DeregisterOption {
|
// DeregisterAttempts specifies deregister atempts count
|
||||||
|
func DeregisterAttempts(t int) DeregisterOption {
|
||||||
return func(o *DeregisterOptions) {
|
return func(o *DeregisterOptions) {
|
||||||
o.Attempts = t
|
o.Attempts = t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DeregisterContext sets the context for deregister method
|
||||||
func DeregisterContext(ctx context.Context) DeregisterOption {
|
func DeregisterContext(ctx context.Context) DeregisterOption {
|
||||||
return func(o *DeregisterOptions) {
|
return func(o *DeregisterOptions) {
|
||||||
o.Context = ctx
|
o.Context = ctx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DeregisterDomain specifies deregister domain
|
||||||
func DeregisterDomain(d string) DeregisterOption {
|
func DeregisterDomain(d string) DeregisterOption {
|
||||||
return func(o *DeregisterOptions) {
|
return func(o *DeregisterOptions) {
|
||||||
o.Domain = d
|
o.Domain = d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LookupContext sets the context for lookup method
|
||||||
func LookupContext(ctx context.Context) LookupOption {
|
func LookupContext(ctx context.Context) LookupOption {
|
||||||
return func(o *LookupOptions) {
|
return func(o *LookupOptions) {
|
||||||
o.Context = ctx
|
o.Context = ctx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LookupDomain sets the domain for lookup
|
||||||
func LookupDomain(d string) LookupOption {
|
func LookupDomain(d string) LookupOption {
|
||||||
return func(o *LookupOptions) {
|
return func(o *LookupOptions) {
|
||||||
o.Domain = d
|
o.Domain = d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListContext specifies context for list method
|
||||||
func ListContext(ctx context.Context) ListOption {
|
func ListContext(ctx context.Context) ListOption {
|
||||||
return func(o *ListOptions) {
|
return func(o *ListOptions) {
|
||||||
o.Context = ctx
|
o.Context = ctx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListDomain sets the domain for list method
|
||||||
func ListDomain(d string) ListOption {
|
func ListDomain(d string) ListOption {
|
||||||
return func(o *ListOptions) {
|
return func(o *ListOptions) {
|
||||||
o.Domain = d
|
o.Domain = d
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Package dns srv resolves names to dns srv records
|
// Package dnssrv resolves names to dns srv records
|
||||||
package dnssrv
|
package dnssrv
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -11,24 +11,23 @@ import (
|
|||||||
"github.com/unistack-org/micro/v3/resolver"
|
"github.com/unistack-org/micro/v3/resolver"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Resolver is a HTTP network resolver
|
// HTTPResolver is a HTTP network resolver
|
||||||
type Resolver struct {
|
type HTTPResolver struct {
|
||||||
// If not set, defaults to http
|
// Proto if not set, defaults to http
|
||||||
Proto string
|
Proto string
|
||||||
|
|
||||||
// Path sets the path to lookup. Defaults to /network
|
// Path sets the path to lookup. Defaults to /network
|
||||||
Path string
|
Path string
|
||||||
|
|
||||||
// Host url to use for the query
|
// Host url to use for the query
|
||||||
Host string
|
Host string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Response contains resolver.Record
|
||||||
type Response struct {
|
type Response struct {
|
||||||
Nodes []*resolver.Record `json:"nodes,omitempty"`
|
Nodes []*resolver.Record `json:"nodes,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolve assumes ID is a domain which can be converted to a http://name/network request
|
// Resolve assumes ID is a domain which can be converted to a http://name/network request
|
||||||
func (r *Resolver) Resolve(name string) ([]*resolver.Record, error) {
|
func (r *HTTPResolver) Resolve(name string) ([]*resolver.Record, error) {
|
||||||
proto := "http"
|
proto := "http"
|
||||||
host := "localhost:8080"
|
host := "localhost:8080"
|
||||||
path := "/network/nodes"
|
path := "/network/nodes"
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"github.com/unistack-org/micro/v3/resolver"
|
"github.com/unistack-org/micro/v3/resolver"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Resolver contains noop resolver
|
||||||
type Resolver struct{}
|
type Resolver struct{}
|
||||||
|
|
||||||
// Resolve returns the list of nodes
|
// Resolve returns the list of nodes
|
||||||
|
@ -8,8 +8,6 @@ import (
|
|||||||
"github.com/unistack-org/micro/v3/logger"
|
"github.com/unistack-org/micro/v3/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Option func(o *Options)
|
|
||||||
|
|
||||||
// Options configure runtime
|
// Options configure runtime
|
||||||
type Options struct {
|
type Options struct {
|
||||||
// Scheduler for updates
|
// Scheduler for updates
|
||||||
@ -26,6 +24,9 @@ type Options struct {
|
|||||||
Logger logger.Logger
|
Logger logger.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Option func signature
|
||||||
|
type Option func(o *Options)
|
||||||
|
|
||||||
// WithLogger sets the logger
|
// WithLogger sets the logger
|
||||||
func WithLogger(l logger.Logger) Option {
|
func WithLogger(l logger.Logger) Option {
|
||||||
return func(o *Options) {
|
return func(o *Options) {
|
||||||
@ -68,8 +69,10 @@ func WithClient(c client.Client) Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CreateOption func signature
|
||||||
type CreateOption func(o *CreateOptions)
|
type CreateOption func(o *CreateOptions)
|
||||||
|
|
||||||
|
// ReadOption func signature
|
||||||
type ReadOption func(o *ReadOptions)
|
type ReadOption func(o *ReadOptions)
|
||||||
|
|
||||||
// CreateOptions configure runtime services
|
// CreateOptions configure runtime services
|
||||||
@ -230,8 +233,10 @@ func ReadContext(ctx context.Context) ReadOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UpdateOption func signature
|
||||||
type UpdateOption func(o *UpdateOptions)
|
type UpdateOption func(o *UpdateOptions)
|
||||||
|
|
||||||
|
// UpdateOptions struct
|
||||||
type UpdateOptions struct {
|
type UpdateOptions struct {
|
||||||
// Namespace the service is running in
|
// Namespace the service is running in
|
||||||
Namespace string
|
Namespace string
|
||||||
@ -241,7 +246,7 @@ type UpdateOptions struct {
|
|||||||
Secrets map[string]string
|
Secrets map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithSecret sets a secret to provide the service with
|
// UpdateSecret sets a secret to provide the service with
|
||||||
func UpdateSecret(key, value string) UpdateOption {
|
func UpdateSecret(key, value string) UpdateOption {
|
||||||
return func(o *UpdateOptions) {
|
return func(o *UpdateOptions) {
|
||||||
if o.Secrets == nil {
|
if o.Secrets == nil {
|
||||||
@ -266,8 +271,10 @@ func UpdateContext(ctx context.Context) UpdateOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DeleteOption func signature
|
||||||
type DeleteOption func(o *DeleteOptions)
|
type DeleteOption func(o *DeleteOptions)
|
||||||
|
|
||||||
|
// DeleteOptions struct
|
||||||
type DeleteOptions struct {
|
type DeleteOptions struct {
|
||||||
// Namespace the service is running in
|
// Namespace the service is running in
|
||||||
Namespace string
|
Namespace string
|
||||||
@ -304,7 +311,7 @@ type LogsOptions struct {
|
|||||||
Context context.Context
|
Context context.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
// LogsExistingCount confiures how many existing lines to show
|
// LogsCount confiures how many existing lines to show
|
||||||
func LogsCount(count int64) LogsOption {
|
func LogsCount(count int64) LogsOption {
|
||||||
return func(l *LogsOptions) {
|
return func(l *LogsOptions) {
|
||||||
l.Count = count
|
l.Count = count
|
||||||
|
@ -136,6 +136,7 @@ func (n *noopServer) String() string {
|
|||||||
return "noop"
|
return "noop"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint:gocyclo
|
||||||
func (n *noopServer) Register() error {
|
func (n *noopServer) Register() error {
|
||||||
n.RLock()
|
n.RLock()
|
||||||
rsvc := n.rsvc
|
rsvc := n.rsvc
|
||||||
@ -144,10 +145,7 @@ func (n *noopServer) Register() error {
|
|||||||
|
|
||||||
// if service already filled, reuse it and return early
|
// if service already filled, reuse it and return early
|
||||||
if rsvc != nil {
|
if rsvc != nil {
|
||||||
if err := DefaultRegisterFunc(rsvc, config); err != nil {
|
return DefaultRegisterFunc(rsvc, config)
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
@ -311,6 +309,7 @@ func (n *noopServer) Deregister() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint:gocyclo
|
||||||
func (n *noopServer) Start() error {
|
func (n *noopServer) Start() error {
|
||||||
n.RLock()
|
n.RLock()
|
||||||
if n.started {
|
if n.started {
|
||||||
|
@ -183,6 +183,7 @@ func newSubscriber(topic string, sub interface{}, opts ...SubscriberOption) Subs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint:gocyclo
|
||||||
func (n *noopServer) createSubHandler(sb *subscriber, opts Options) broker.Handler {
|
func (n *noopServer) createSubHandler(sb *subscriber, opts Options) broker.Handler {
|
||||||
return func(p broker.Event) (err error) {
|
return func(p broker.Event) (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -88,6 +88,7 @@ func (s *service) Name() string {
|
|||||||
// Init initialises options. Additionally it calls cmd.Init
|
// Init initialises options. Additionally it calls cmd.Init
|
||||||
// which parses command line flags. cmd.Init is only called
|
// which parses command line flags. cmd.Init is only called
|
||||||
// on first Init.
|
// on first Init.
|
||||||
|
//nolint:gocyclo
|
||||||
func (s *service) Init(opts ...Option) error {
|
func (s *service) Init(opts ...Option) error {
|
||||||
var err error
|
var err error
|
||||||
// process options
|
// process options
|
||||||
@ -248,6 +249,7 @@ func (s *service) String() string {
|
|||||||
return "micro"
|
return "micro"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint:gocyclo
|
||||||
func (s *service) Start() error {
|
func (s *service) Start() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
@ -70,11 +70,7 @@ func (m *memoryStore) get(prefix, key string, val interface{}) error {
|
|||||||
return ErrNotFound
|
return ErrNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := m.opts.Codec.Unmarshal(buf, val); err != nil {
|
return m.opts.Codec.Unmarshal(buf, val)
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *memoryStore) delete(prefix, key string) {
|
func (m *memoryStore) delete(prefix, key string) {
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/unistack-org/micro/v3/tracer"
|
"github.com/unistack-org/micro/v3/tracer"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Options holds the sync options
|
||||||
type Options struct {
|
type Options struct {
|
||||||
Nodes []string
|
Nodes []string
|
||||||
Prefix string
|
Prefix string
|
||||||
@ -16,8 +17,10 @@ type Options struct {
|
|||||||
Meter meter.Meter
|
Meter meter.Meter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Option func signature
|
||||||
type Option func(o *Options)
|
type Option func(o *Options)
|
||||||
|
|
||||||
|
// NewOptions returns options that filled by opts
|
||||||
func NewOptions(opts ...Option) Options {
|
func NewOptions(opts ...Option) Options {
|
||||||
options := Options{
|
options := Options{
|
||||||
Logger: logger.DefaultLogger,
|
Logger: logger.DefaultLogger,
|
||||||
@ -32,15 +35,19 @@ func NewOptions(opts ...Option) Options {
|
|||||||
return options
|
return options
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LeaderOptions holds the leader options
|
||||||
type LeaderOptions struct{}
|
type LeaderOptions struct{}
|
||||||
|
|
||||||
|
// LeaderOption func signature
|
||||||
type LeaderOption func(o *LeaderOptions)
|
type LeaderOption func(o *LeaderOptions)
|
||||||
|
|
||||||
|
// LockOptions holds the lock options
|
||||||
type LockOptions struct {
|
type LockOptions struct {
|
||||||
TTL time.Duration
|
TTL time.Duration
|
||||||
Wait time.Duration
|
Wait time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LockOption func signature
|
||||||
type LockOption func(o *LockOptions)
|
type LockOption func(o *LockOptions)
|
||||||
|
|
||||||
// Logger sets the logger
|
// Logger sets the logger
|
||||||
|
@ -60,6 +60,7 @@ func IsLocal(addr string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Extract returns a real ip
|
// Extract returns a real ip
|
||||||
|
//nolint:gocyclo
|
||||||
func Extract(addr string) (string, error) {
|
func Extract(addr string) (string, error) {
|
||||||
// if addr specified then its returned
|
// if addr specified then its returned
|
||||||
if len(addr) > 0 && (addr != "0.0.0.0" && addr != "[::]" && addr != "::") {
|
if len(addr) > 0 && (addr != "0.0.0.0" && addr != "[::]" && addr != "::") {
|
||||||
|
@ -8,11 +8,13 @@ type buffer struct {
|
|||||||
*bytes.Buffer
|
*bytes.Buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Close reset buffer contents
|
||||||
func (b *buffer) Close() error {
|
func (b *buffer) Close() error {
|
||||||
b.Buffer.Reset()
|
b.Buffer.Reset()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// New creates new buffer that satisfies Closer interface
|
||||||
func New(b *bytes.Buffer) *buffer {
|
func New(b *bytes.Buffer) *buffer {
|
||||||
if b == nil {
|
if b == nil {
|
||||||
b = bytes.NewBuffer(nil)
|
b = bytes.NewBuffer(nil)
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/unistack-org/micro/v3/metadata"
|
"github.com/unistack-org/micro/v3/metadata"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// FromRequest creates context with metadata from http.Request
|
||||||
func FromRequest(r *http.Request) context.Context {
|
func FromRequest(r *http.Request) context.Context {
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
md, ok := metadata.FromIncomingContext(ctx)
|
md, ok := metadata.FromIncomingContext(ctx)
|
||||||
|
@ -44,6 +44,7 @@ func WriteInternalServerError(w http.ResponseWriter, err error) {
|
|||||||
Write(w, "application/json", 500, string(rawBody))
|
Write(w, "application/json", 500, string(rawBody))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewRoundTripper creates new http RoundTripper
|
||||||
func NewRoundTripper(opts ...Option) http.RoundTripper {
|
func NewRoundTripper(opts ...Option) http.RoundTripper {
|
||||||
options := Options{}
|
options := Options{}
|
||||||
for _, o := range opts {
|
for _, o := range opts {
|
||||||
|
@ -6,26 +6,31 @@ import (
|
|||||||
"github.com/unistack-org/micro/v3/network/transport"
|
"github.com/unistack-org/micro/v3/network/transport"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Options struct
|
||||||
type Options struct {
|
type Options struct {
|
||||||
Transport transport.Transport
|
Transport transport.Transport
|
||||||
TTL time.Duration
|
TTL time.Duration
|
||||||
Size int
|
Size int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Option func signature
|
||||||
type Option func(*Options)
|
type Option func(*Options)
|
||||||
|
|
||||||
|
// Size sets the size
|
||||||
func Size(i int) Option {
|
func Size(i int) Option {
|
||||||
return func(o *Options) {
|
return func(o *Options) {
|
||||||
o.Size = i
|
o.Size = i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Transport sets the transport
|
||||||
func Transport(t transport.Transport) Option {
|
func Transport(t transport.Transport) Option {
|
||||||
return func(o *Options) {
|
return func(o *Options) {
|
||||||
o.Transport = t
|
o.Transport = t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TTL specifies ttl
|
||||||
func TTL(t time.Duration) Option {
|
func TTL(t time.Duration) Option {
|
||||||
return func(o *Options) {
|
return func(o *Options) {
|
||||||
o.TTL = t
|
o.TTL = t
|
||||||
|
@ -18,6 +18,7 @@ type Pool interface {
|
|||||||
Release(c Conn, status error) error
|
Release(c Conn, status error) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Conn conn pool interface
|
||||||
type Conn interface {
|
type Conn interface {
|
||||||
// unique id of connection
|
// unique id of connection
|
||||||
Id() string
|
Id() string
|
||||||
@ -27,8 +28,9 @@ type Conn interface {
|
|||||||
transport.Client
|
transport.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewPool creates new connection pool
|
||||||
func NewPool(opts ...Option) Pool {
|
func NewPool(opts ...Option) Pool {
|
||||||
var options Options
|
options := Options{}
|
||||||
for _, o := range opts {
|
for _, o := range opts {
|
||||||
o(&options)
|
o(&options)
|
||||||
}
|
}
|
||||||
|
@ -208,6 +208,7 @@ func FlattenMap(a map[string]interface{}) map[string]interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MergeMap merges maps
|
// MergeMap merges maps
|
||||||
|
//nolint:gocyclo
|
||||||
func MergeMap(a interface{}, b map[string]interface{}) error {
|
func MergeMap(a interface{}, b map[string]interface{}) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
@ -281,6 +282,7 @@ func MergeMap(a interface{}, b map[string]interface{}) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint:gocyclo
|
||||||
func mergeSlice(va, vb reflect.Value) error {
|
func mergeSlice(va, vb reflect.Value) error {
|
||||||
switch getKind(vb) {
|
switch getKind(vb) {
|
||||||
/*
|
/*
|
||||||
|
@ -78,7 +78,7 @@ func (b *Buffer) Get(n int) []*Entry {
|
|||||||
return b.vals[delta:]
|
return b.vals[delta:]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the entries since a specific time
|
// Since returns the entries since a specific time
|
||||||
func (b *Buffer) Since(t time.Time) []*Entry {
|
func (b *Buffer) Since(t time.Time) []*Entry {
|
||||||
b.RLock()
|
b.RLock()
|
||||||
defer b.RUnlock()
|
defer b.RUnlock()
|
||||||
|
@ -276,6 +276,7 @@ func (p *parser) accept(term termType) (string, error) {
|
|||||||
// sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
|
// sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
|
||||||
// / "*" / "+" / "," / ";" / "="
|
// / "*" / "+" / "," / ";" / "="
|
||||||
// pct-encoded = "%" HEXDIG HEXDIG
|
// pct-encoded = "%" HEXDIG HEXDIG
|
||||||
|
//nolint:gocyclo
|
||||||
func expectPChars(t string) error {
|
func expectPChars(t string) error {
|
||||||
const (
|
const (
|
||||||
init = iota
|
init = iota
|
||||||
|
@ -54,6 +54,7 @@ type PatternOpt func(*patternOptions)
|
|||||||
// "verb" is the verb part of the pattern. It is empty if the pattern does not have the part.
|
// "verb" is the verb part of the pattern. It is empty if the pattern does not have the part.
|
||||||
// "version" must be 1 for now.
|
// "version" must be 1 for now.
|
||||||
// It returns an error if the given definition is invalid.
|
// It returns an error if the given definition is invalid.
|
||||||
|
//nolint:gocyclo
|
||||||
func NewPattern(version int, ops []int, pool []string, verb string, opts ...PatternOpt) (Pattern, error) {
|
func NewPattern(version int, ops []int, pool []string, verb string, opts ...PatternOpt) (Pattern, error) {
|
||||||
options := patternOptions{
|
options := patternOptions{
|
||||||
assumeColonVerb: true,
|
assumeColonVerb: true,
|
||||||
@ -182,6 +183,7 @@ func MustPattern(p Pattern, err error) Pattern {
|
|||||||
// Match examines components if it matches to the Pattern.
|
// Match examines components if it matches to the Pattern.
|
||||||
// If it matches, the function returns a mapping from field paths to their captured values.
|
// If it matches, the function returns a mapping from field paths to their captured values.
|
||||||
// If otherwise, the function returns an error.
|
// If otherwise, the function returns an error.
|
||||||
|
//nolint:gocyclo
|
||||||
func (p Pattern) Match(components []string, verb string) (map[string]string, error) {
|
func (p Pattern) Match(components []string, verb string) (map[string]string, error) {
|
||||||
if p.verb != verb {
|
if p.verb != verb {
|
||||||
if p.assumeColonVerb || p.verb != "" {
|
if p.assumeColonVerb || p.verb != "" {
|
||||||
|
@ -4,11 +4,13 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Pool holds the socket pool
|
||||||
type Pool struct {
|
type Pool struct {
|
||||||
sync.RWMutex
|
sync.RWMutex
|
||||||
pool map[string]*Socket
|
pool map[string]*Socket
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get socket from pool
|
||||||
func (p *Pool) Get(id string) (*Socket, bool) {
|
func (p *Pool) Get(id string) (*Socket, bool) {
|
||||||
// attempt to get existing socket
|
// attempt to get existing socket
|
||||||
p.RLock()
|
p.RLock()
|
||||||
@ -35,6 +37,7 @@ func (p *Pool) Get(id string) (*Socket, bool) {
|
|||||||
return socket, false
|
return socket, false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Release close the socket and delete from pool
|
||||||
func (p *Pool) Release(s *Socket) {
|
func (p *Pool) Release(s *Socket) {
|
||||||
p.Lock()
|
p.Lock()
|
||||||
defer p.Unlock()
|
defer p.Unlock()
|
||||||
|
@ -22,10 +22,12 @@ type Socket struct {
|
|||||||
recv chan *transport.Message
|
recv chan *transport.Message
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetLocal sets the local addr
|
||||||
func (s *Socket) SetLocal(l string) {
|
func (s *Socket) SetLocal(l string) {
|
||||||
s.local = l
|
s.local = l
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetRemote sets the remote addr
|
||||||
func (s *Socket) SetRemote(r string) {
|
func (s *Socket) SetRemote(r string) {
|
||||||
s.remote = r
|
s.remote = r
|
||||||
}
|
}
|
||||||
@ -58,14 +60,17 @@ func (s *Socket) Process(m *transport.Message) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remote returns remote addr
|
||||||
func (s *Socket) Remote() string {
|
func (s *Socket) Remote() string {
|
||||||
return s.remote
|
return s.remote
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Local returns local addr
|
||||||
func (s *Socket) Local() string {
|
func (s *Socket) Local() string {
|
||||||
return s.local
|
return s.local
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send message by via transport
|
||||||
func (s *Socket) Send(m *transport.Message) error {
|
func (s *Socket) Send(m *transport.Message) error {
|
||||||
// send a message
|
// send a message
|
||||||
select {
|
select {
|
||||||
@ -77,6 +82,7 @@ func (s *Socket) Send(m *transport.Message) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Recv message from transport
|
||||||
func (s *Socket) Recv(m *transport.Message) error {
|
func (s *Socket) Recv(m *transport.Message) error {
|
||||||
// receive a message
|
// receive a message
|
||||||
select {
|
select {
|
||||||
|
@ -11,10 +11,11 @@ import (
|
|||||||
"github.com/unistack-org/micro/v3/server"
|
"github.com/unistack-org/micro/v3/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Stream interface
|
||||||
type Stream interface {
|
type Stream interface {
|
||||||
Context() context.Context
|
Context() context.Context
|
||||||
SendMsg(interface{}) error
|
SendMsg(msg interface{}) error
|
||||||
RecvMsg(interface{}) error
|
RecvMsg(msg interface{}) error
|
||||||
Close() error
|
Close() error
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,23 +32,28 @@ type request struct {
|
|||||||
context context.Context
|
context context.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Codec returns codec.Codec
|
||||||
func (r *request) Codec() codec.Codec {
|
func (r *request) Codec() codec.Codec {
|
||||||
return r.Request.Codec()
|
return r.Request.Codec()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Header returns metadata header
|
||||||
func (r *request) Header() metadata.Metadata {
|
func (r *request) Header() metadata.Metadata {
|
||||||
md, _ := metadata.FromIncomingContext(r.context)
|
md, _ := metadata.FromIncomingContext(r.context)
|
||||||
return md
|
return md
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Read returns stream data
|
||||||
func (r *request) Read() ([]byte, error) {
|
func (r *request) Read() ([]byte, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Request returns server.Request
|
||||||
func (s *stream) Request() server.Request {
|
func (s *stream) Request() server.Request {
|
||||||
return s.request
|
return s.request
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send sends message
|
||||||
func (s *stream) Send(v interface{}) error {
|
func (s *stream) Send(v interface{}) error {
|
||||||
err := s.Stream.SendMsg(v)
|
err := s.Stream.SendMsg(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -58,6 +64,7 @@ func (s *stream) Send(v interface{}) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Recv receives data
|
||||||
func (s *stream) Recv(v interface{}) error {
|
func (s *stream) Recv(v interface{}) error {
|
||||||
err := s.Stream.RecvMsg(v)
|
err := s.Stream.RecvMsg(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -68,6 +75,7 @@ func (s *stream) Recv(v interface{}) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Error returns error that stream holds
|
||||||
func (s *stream) Error() error {
|
func (s *stream) Error() error {
|
||||||
s.RLock()
|
s.RLock()
|
||||||
defer s.RUnlock()
|
defer s.RUnlock()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Package syncs will sync multiple stores
|
// Package sync will sync multiple stores
|
||||||
package sync
|
package sync
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"github.com/unistack-org/micro/v3/store"
|
"github.com/unistack-org/micro/v3/store"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Options holds the options for token
|
||||||
type Options struct {
|
type Options struct {
|
||||||
// Store to persist the tokens
|
// Store to persist the tokens
|
||||||
Store store.Store
|
Store store.Store
|
||||||
@ -15,6 +16,7 @@ type Options struct {
|
|||||||
PrivateKey string
|
PrivateKey string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Option func signature
|
||||||
type Option func(o *Options)
|
type Option func(o *Options)
|
||||||
|
|
||||||
// WithStore sets the token providers store
|
// WithStore sets the token providers store
|
||||||
@ -38,8 +40,9 @@ func WithPrivateKey(key string) Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewOptions returns options struct filled by opts
|
||||||
func NewOptions(opts ...Option) Options {
|
func NewOptions(opts ...Option) Options {
|
||||||
var options Options
|
options := Options{}
|
||||||
for _, o := range opts {
|
for _, o := range opts {
|
||||||
o(&options)
|
o(&options)
|
||||||
}
|
}
|
||||||
@ -50,11 +53,13 @@ func NewOptions(opts ...Option) Options {
|
|||||||
return options
|
return options
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GenerateOptions holds the generate options
|
||||||
type GenerateOptions struct {
|
type GenerateOptions struct {
|
||||||
// Expiry for the token
|
// Expiry for the token
|
||||||
Expiry time.Duration
|
Expiry time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GenerateOption func signature
|
||||||
type GenerateOption func(o *GenerateOptions)
|
type GenerateOption func(o *GenerateOptions)
|
||||||
|
|
||||||
// WithExpiry for the generated account's token expires
|
// WithExpiry for the generated account's token expires
|
||||||
|
@ -23,6 +23,7 @@ type Provider interface {
|
|||||||
String() string
|
String() string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Token holds the auth token
|
||||||
type Token struct {
|
type Token struct {
|
||||||
// The actual token
|
// The actual token
|
||||||
Token string `json:"token"`
|
Token string `json:"token"`
|
||||||
|
Loading…
Reference in New Issue
Block a user