store/options: extend options to holds name and timeout
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
		| @@ -144,6 +144,10 @@ type ReadOptions struct { | |||||||
| 	Context context.Context | 	Context context.Context | ||||||
| 	// Namespace holds namespace | 	// Namespace holds namespace | ||||||
| 	Namespace string | 	Namespace string | ||||||
|  | 	// Name holds mnemonic name | ||||||
|  | 	Name string | ||||||
|  | 	// Timeout specifies max timeout for operation | ||||||
|  | 	Timeout time.Duration | ||||||
| } | } | ||||||
|  |  | ||||||
| // NewReadOptions fills ReadOptions struct with opts slice | // NewReadOptions fills ReadOptions struct with opts slice | ||||||
| @@ -158,6 +162,20 @@ func NewReadOptions(opts ...ReadOption) ReadOptions { | |||||||
| // ReadOption sets values in ReadOptions | // ReadOption sets values in ReadOptions | ||||||
| type ReadOption func(r *ReadOptions) | type ReadOption func(r *ReadOptions) | ||||||
|  |  | ||||||
|  | // ReadTimeout pass timeout to ReadOptions | ||||||
|  | func ReadTimeout(td time.Duration) ReadOption { | ||||||
|  | 	return func(o *ReadOptions) { | ||||||
|  | 		o.Timeout = td | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // ReadName pass name to ReadOptions | ||||||
|  | func ReadName(name string) ReadOption { | ||||||
|  | 	return func(o *ReadOptions) { | ||||||
|  | 		o.Name = name | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
| // ReadContext pass context.Context to ReadOptions | // ReadContext pass context.Context to ReadOptions | ||||||
| func ReadContext(ctx context.Context) ReadOption { | func ReadContext(ctx context.Context) ReadOption { | ||||||
| 	return func(o *ReadOptions) { | 	return func(o *ReadOptions) { | ||||||
| @@ -180,6 +198,10 @@ type WriteOptions struct { | |||||||
| 	Metadata metadata.Metadata | 	Metadata metadata.Metadata | ||||||
| 	// Namespace holds namespace | 	// Namespace holds namespace | ||||||
| 	Namespace string | 	Namespace string | ||||||
|  | 	// Name holds mnemonic name | ||||||
|  | 	Name string | ||||||
|  | 	// Timeout specifies max timeout for operation | ||||||
|  | 	Timeout time.Duration | ||||||
| 	// TTL specifies key TTL | 	// TTL specifies key TTL | ||||||
| 	TTL time.Duration | 	TTL time.Duration | ||||||
| } | } | ||||||
| @@ -224,12 +246,30 @@ func WriteNamespace(ns string) WriteOption { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // WriteName pass name to WriteOptions | ||||||
|  | func WriteName(name string) WriteOption { | ||||||
|  | 	return func(o *WriteOptions) { | ||||||
|  | 		o.Name = name | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // WriteTimeout pass timeout to WriteOptions | ||||||
|  | func WriteTimeout(td time.Duration) WriteOption { | ||||||
|  | 	return func(o *WriteOptions) { | ||||||
|  | 		o.Timeout = td | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
| // DeleteOptions configures an individual Delete operation | // DeleteOptions configures an individual Delete operation | ||||||
| type DeleteOptions struct { | type DeleteOptions struct { | ||||||
| 	// Context holds external options | 	// Context holds external options | ||||||
| 	Context context.Context | 	Context context.Context | ||||||
| 	// Namespace holds namespace | 	// Namespace holds namespace | ||||||
| 	Namespace string | 	Namespace string | ||||||
|  | 	// Name holds mnemonic name | ||||||
|  | 	Name string | ||||||
|  | 	// Timeout specifies max timeout for operation | ||||||
|  | 	Timeout time.Duration | ||||||
| } | } | ||||||
|  |  | ||||||
| // NewDeleteOptions fills DeleteOptions struct with opts slice | // NewDeleteOptions fills DeleteOptions struct with opts slice | ||||||
| @@ -258,14 +298,32 @@ func DeleteNamespace(ns string) DeleteOption { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // DeleteName pass name to DeleteOptions | ||||||
|  | func DeleteName(name string) DeleteOption { | ||||||
|  | 	return func(o *DeleteOptions) { | ||||||
|  | 		o.Name = name | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // DeleteTimeout pass timeout to DeleteOptions | ||||||
|  | func DeleteTimeout(td time.Duration) DeleteOption { | ||||||
|  | 	return func(o *DeleteOptions) { | ||||||
|  | 		o.Timeout = td | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
| // ListOptions configures an individual List operation | // ListOptions configures an individual List operation | ||||||
| type ListOptions struct { | type ListOptions struct { | ||||||
| 	Context   context.Context | 	Context   context.Context | ||||||
| 	Prefix    string | 	Prefix    string | ||||||
| 	Suffix    string | 	Suffix    string | ||||||
| 	Namespace string | 	Namespace string | ||||||
|  | 	// Name holds mnemonic name | ||||||
|  | 	Name   string | ||||||
| 	Limit  uint | 	Limit  uint | ||||||
| 	Offset uint | 	Offset uint | ||||||
|  | 	// Timeout specifies max timeout for operation | ||||||
|  | 	Timeout time.Duration | ||||||
| } | } | ||||||
|  |  | ||||||
| // NewListOptions fills ListOptions struct with opts slice | // NewListOptions fills ListOptions struct with opts slice | ||||||
| @@ -322,12 +380,23 @@ func ListNamespace(ns string) ListOption { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // ListTimeout pass timeout to ListOptions | ||||||
|  | func ListTimeout(td time.Duration) ListOption { | ||||||
|  | 	return func(o *ListOptions) { | ||||||
|  | 		o.Timeout = td | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
| // ExistsOptions holds options for Exists method | // ExistsOptions holds options for Exists method | ||||||
| type ExistsOptions struct { | type ExistsOptions struct { | ||||||
| 	// Context holds external options | 	// Context holds external options | ||||||
| 	Context context.Context | 	Context context.Context | ||||||
| 	// Namespace contains namespace | 	// Namespace contains namespace | ||||||
| 	Namespace string | 	Namespace string | ||||||
|  | 	// Name holds mnemonic name | ||||||
|  | 	Name string | ||||||
|  | 	// Timeout specifies max timeout for operation | ||||||
|  | 	Timeout time.Duration | ||||||
| } | } | ||||||
|  |  | ||||||
| // ExistsOption specifies Exists call options | // ExistsOption specifies Exists call options | ||||||
| @@ -358,6 +427,20 @@ func ExistsNamespace(ns string) ExistsOption { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // ExistsName pass name to exist options | ||||||
|  | func ExistsName(name string) ExistsOption { | ||||||
|  | 	return func(o *ExistsOptions) { | ||||||
|  | 		o.Name = name | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // ExistsTimeout timeout to ListOptions | ||||||
|  | func ExistsTimeout(td time.Duration) ExistsOption { | ||||||
|  | 	return func(o *ExistsOptions) { | ||||||
|  | 		o.Timeout = td | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
| /* | /* | ||||||
| // WrapStore adds a store Wrapper to a list of options passed into the store | // WrapStore adds a store Wrapper to a list of options passed into the store | ||||||
| func WrapStore(w Wrapper) Option { | func WrapStore(w Wrapper) Option { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user