Merge pull request #153 from unistack-org/client_metadata

client: add req/rsp metadata to CallOptions
This commit is contained in:
Василий Толстов 2022-11-14 15:31:58 +03:00 committed by GitHub
commit 42864ff1c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -98,6 +98,10 @@ type CallOptions struct {
StreamTimeout time.Duration StreamTimeout time.Duration
// RequestTimeout request timeout // RequestTimeout request timeout
RequestTimeout time.Duration RequestTimeout time.Duration
// RequestMetadata holds additional metadata for call
RequestMetadata metadata.Metadata
// ResponseMetadata holds additional metadata from call
ResponseMetadata metadata.Metadata
// DialTimeout dial timeout // DialTimeout dial timeout
DialTimeout time.Duration DialTimeout time.Duration
// Retries specifies retries num // Retries specifies retries num
@ -477,6 +481,20 @@ func WithRetries(i int) CallOption {
} }
} }
// WithResponseMetadata is a CallOption which adds metadata.Metadata to Options.CallOptions
func WithResponseMetadata(md metadata.Metadata) CallOption {
return func(o *CallOptions) {
o.ResponseMetadata = md
}
}
// WithRequestMetadata is a CallOption which adds metadata.Metadata to Options.CallOptions
func WithRequestMetadata(md metadata.Metadata) CallOption {
return func(o *CallOptions) {
o.RequestMetadata = md
}
}
// WithRequestTimeout is a CallOption which overrides that which // WithRequestTimeout is a CallOption which overrides that which
// set in Options.CallOptions // set in Options.CallOptions
func WithRequestTimeout(d time.Duration) CallOption { func WithRequestTimeout(d time.Duration) CallOption {