mirror of
https://github.com/go-micro/go-micro.git
synced 2024-11-24 08:02:32 +02:00
Satisfy the golint gods a little
This commit is contained in:
parent
5fb1051e0b
commit
2f50c74f41
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
The client package provides a method to make synchronous, asynchronous and
|
Package client provides a method to make synchronous, asynchronous and
|
||||||
streaming requests to services. By default json and protobuf codecs are
|
streaming requests to services. By default json and protobuf codecs are
|
||||||
supported.
|
supported.
|
||||||
|
|
||||||
@ -45,12 +45,14 @@ type Client interface {
|
|||||||
String() string
|
String() string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Publication is the interface for a message published asynchronously
|
||||||
type Publication interface {
|
type Publication interface {
|
||||||
Topic() string
|
Topic() string
|
||||||
Message() interface{}
|
Message() interface{}
|
||||||
ContentType() string
|
ContentType() string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Request is the interface for a synchronous request used by Call or Stream
|
||||||
type Request interface {
|
type Request interface {
|
||||||
Service() string
|
Service() string
|
||||||
Method() string
|
Method() string
|
||||||
@ -60,6 +62,7 @@ type Request interface {
|
|||||||
Stream() bool
|
Stream() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Streamer is the inteface for a bidirectional synchronous stream
|
||||||
type Streamer interface {
|
type Streamer interface {
|
||||||
Context() context.Context
|
Context() context.Context
|
||||||
Request() Request
|
Request() Request
|
||||||
@ -69,16 +72,28 @@ type Streamer interface {
|
|||||||
Close() error
|
Close() error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Option used by the Client
|
||||||
type Option func(*Options)
|
type Option func(*Options)
|
||||||
|
|
||||||
|
// CallOption used by Call or Stream
|
||||||
type CallOption func(*CallOptions)
|
type CallOption func(*CallOptions)
|
||||||
|
|
||||||
|
// PublishOption used by Publish
|
||||||
type PublishOption func(*PublishOptions)
|
type PublishOption func(*PublishOptions)
|
||||||
|
|
||||||
|
// RequestOption used by NewRequest
|
||||||
type RequestOption func(*RequestOptions)
|
type RequestOption func(*RequestOptions)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
// DefaultClient is a default client to use out of the box
|
||||||
DefaultClient Client = newRpcClient()
|
DefaultClient Client = newRpcClient()
|
||||||
|
|
||||||
DefaultBackoff = exponentialBackoff
|
// DefaultBackoff is the default backoff function for retries
|
||||||
DefaultRetries = 1
|
DefaultBackoff = exponentialBackoff
|
||||||
|
|
||||||
|
// DefaultRetries is the default number of times a request is tried
|
||||||
|
DefaultRetries = 1
|
||||||
|
// DefaultRequestTimeout is the default request timeout
|
||||||
DefaultRequestTimeout = time.Second * 5
|
DefaultRequestTimeout = time.Second * 5
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -93,7 +108,7 @@ func CallRemote(ctx context.Context, address string, request Request, response i
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Creates a streaming connection with a service and returns responses on the
|
// Creates a streaming connection with a service and returns responses on the
|
||||||
// channel passed in. It's upto the user to close the streamer.
|
// channel passed in. It's up to the user to close the streamer.
|
||||||
func Stream(ctx context.Context, request Request, opts ...CallOption) (Streamer, error) {
|
func Stream(ctx context.Context, request Request, opts ...CallOption) (Streamer, error) {
|
||||||
return DefaultClient.Stream(ctx, request, opts...)
|
return DefaultClient.Stream(ctx, request, opts...)
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ func (r *rpcStream) Recv(msg interface{}) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// we need to stay upto date with sequence numbers
|
// we need to stay up to date with sequence numbers
|
||||||
r.seq = req.Seq
|
r.seq = req.Seq
|
||||||
|
|
||||||
if err := r.codec.ReadRequestBody(msg); err != nil {
|
if err := r.codec.ReadRequestBody(msg); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user