Documentation ¶
Overview ¶
*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.
*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.
*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.
*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.
*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.
*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.
*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.
Index ¶
- Variables
- func Register(b Tasker)
- type CompletedConfig
- type Config
- type ConfigOption
- type ConfigOptionFunc
- type EmptyConfigOption
- type EmptyPoolOption
- type Pool
- func (o *Pool) ApplyOptions(options ...PoolOption) *Pool
- func (p *Pool) Consume(ctx context.Context) (err error)
- func (p *Pool) FetchResult(ctx context.Context, key string) (*queue_.MessageResult, error)
- func (p *Pool) Publish(ctx context.Context, msg *queue_.Message) (string, error)
- func (p *Pool) Work(ctx context.Context, msg *queue_.Message) error
- type PoolOption
- func WithFetchTimeout(timeout time.Duration) PoolOption
- func WithFetcherBurst(burst uint32) PoolOption
- func WithResultCallbackFunc(callback queue_.ResultCallbackFunc) PoolOption
- func WithResultExpired(resultExpired time.Duration) PoolOption
- func WithWorkTimeout(timeout time.Duration) PoolOption
- func WithWorkerBurst(burst uint32) PoolOption
- type PoolOptionFunc
- type PoolOptions
- type Task
- type TaskOptions
- type TaskQueue
- func (*TaskQueue) Descriptor() ([]byte, []int)deprecated
- func (x *TaskQueue) GetEnabled() bool
- func (x *TaskQueue) GetFetchTimeout() *duration.Duration
- func (x *TaskQueue) GetFetcherBurst() uint32
- func (x *TaskQueue) GetQueueType() TaskQueue_QueueType
- func (x *TaskQueue) GetResultExpired() *duration.Duration
- func (x *TaskQueue) GetWorkTimeout() *duration.Duration
- func (x *TaskQueue) GetWorkerBurst() uint32
- func (*TaskQueue) ProtoMessage()
- func (x *TaskQueue) ProtoReflect() protoreflect.Message
- func (x *TaskQueue) Reset()
- func (x *TaskQueue) String() string
- type TaskQueue_QueueType
- func (TaskQueue_QueueType) Descriptor() protoreflect.EnumDescriptor
- func (x TaskQueue_QueueType) Enum() *TaskQueue_QueueType
- func (TaskQueue_QueueType) EnumDescriptor() ([]byte, []int)deprecated
- func (x TaskQueue_QueueType) Number() protoreflect.EnumNumber
- func (x TaskQueue_QueueType) String() string
- func (TaskQueue_QueueType) Type() protoreflect.EnumType
- type Tasker
- type TaskerMap
- func (m *TaskerMap) Delete(key string)
- func (m *TaskerMap) Load(key string) (Tasker, bool)
- func (m *TaskerMap) LoadAndDelete(key string) (value Tasker, loaded bool)
- func (m *TaskerMap) LoadOrStore(key string, value Tasker) (Tasker, bool)
- func (m *TaskerMap) Range(f func(key string, value Tasker) bool)
- func (m *TaskerMap) Store(key string, value Tasker)
Constants ¶
This section is empty.
Variables ¶
var ( TaskQueue_QueueType_name = map[int32]string{ 0: "queue_type_redis", } TaskQueue_QueueType_value = map[string]int32{ "queue_type_redis": 0, } )
Enum value maps for TaskQueue_QueueType.
var File_pkg_pool_taskqueue_taskqueue_proto protoreflect.FileDescriptor
Functions ¶
Types ¶
type CompletedConfig ¶
type CompletedConfig struct {
// contains filtered or unexported fields
}
type Config ¶
type Config struct { Proto TaskQueue // contains filtered or unexported fields }
func NewConfig ¶
func NewConfig(options ...ConfigOption) *Config
func (*Config) ApplyOptions ¶
func (o *Config) ApplyOptions(options ...ConfigOption) *Config
func (*Config) Complete ¶
func (c *Config) Complete() CompletedConfig
Complete set default ServerRunOptions.
type ConfigOption ¶
type ConfigOption interface {
// contains filtered or unexported methods
}
A ConfigOption sets options.
func WithViper ¶
func WithViper(v *viper.Viper) ConfigOption
type ConfigOptionFunc ¶
type ConfigOptionFunc func(*Config)
ConfigOptionFunc wraps a function that modifies Client into an implementation of the ConfigOption interface.
type EmptyConfigOption ¶
type EmptyConfigOption struct{}
EmptyConfigOption does not alter the configuration. It can be embedded in another structure to build custom options.
This API is EXPERIMENTAL.
type EmptyPoolOption ¶
type EmptyPoolOption struct{}
EmptyPoolUrlOption does not alter the Pooluration. It can be embedded in another structure to build custom options.
This API is EXPERIMENTAL.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
func (*Pool) ApplyOptions ¶
func (o *Pool) ApplyOptions(options ...PoolOption) *Pool
func (*Pool) FetchResult ¶
type PoolOption ¶
type PoolOption interface {
// contains filtered or unexported methods
}
A PoolOption sets options.
func WithFetchTimeout ¶
func WithFetchTimeout(timeout time.Duration) PoolOption
func WithFetcherBurst ¶
func WithFetcherBurst(burst uint32) PoolOption
func WithResultCallbackFunc ¶
func WithResultCallbackFunc(callback queue_.ResultCallbackFunc) PoolOption
func WithResultExpired ¶
func WithResultExpired(resultExpired time.Duration) PoolOption
func WithWorkTimeout ¶
func WithWorkTimeout(timeout time.Duration) PoolOption
func WithWorkerBurst ¶
func WithWorkerBurst(burst uint32) PoolOption
type PoolOptionFunc ¶
type PoolOptionFunc func(*Pool)
PoolOptionFunc wraps a function that modifies Pool into an implementation of the PoolOption interface.
type PoolOptions ¶
type PoolOptions struct {
// contains filtered or unexported fields
}
type TaskOptions ¶
type TaskOptions struct {
Name string
}
type TaskQueue ¶
type TaskQueue struct { Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"` WorkerBurst uint32 `protobuf:"varint,2,opt,name=worker_burst,json=workerBurst,proto3" json:"worker_burst,omitempty"` FetcherBurst uint32 `protobuf:"varint,3,opt,name=fetcher_burst,json=fetcherBurst,proto3" json:"fetcher_burst,omitempty"` WorkTimeout *duration.Duration `protobuf:"bytes,4,opt,name=work_timeout,json=workTimeout,proto3" json:"work_timeout,omitempty"` FetchTimeout *duration.Duration `protobuf:"bytes,5,opt,name=fetch_timeout,json=fetchTimeout,proto3" json:"fetch_timeout,omitempty"` ResultExpired *duration.Duration `protobuf:"bytes,6,opt,name=result_expired,json=resultExpired,proto3" json:"result_expired,omitempty"` QueueType TaskQueue_QueueType `` /* 136-byte string literal not displayed */ // contains filtered or unexported fields }
func (*TaskQueue) Descriptor
deprecated
func (*TaskQueue) GetEnabled ¶
func (*TaskQueue) GetFetchTimeout ¶
func (*TaskQueue) GetFetcherBurst ¶
func (*TaskQueue) GetQueueType ¶
func (x *TaskQueue) GetQueueType() TaskQueue_QueueType
func (*TaskQueue) GetResultExpired ¶
func (*TaskQueue) GetWorkTimeout ¶
func (*TaskQueue) GetWorkerBurst ¶
func (*TaskQueue) ProtoMessage ¶
func (*TaskQueue) ProtoMessage()
func (*TaskQueue) ProtoReflect ¶
func (x *TaskQueue) ProtoReflect() protoreflect.Message
type TaskQueue_QueueType ¶
type TaskQueue_QueueType int32
const (
TaskQueue_queue_type_redis TaskQueue_QueueType = 0
)
func (TaskQueue_QueueType) Descriptor ¶
func (TaskQueue_QueueType) Descriptor() protoreflect.EnumDescriptor
func (TaskQueue_QueueType) Enum ¶
func (x TaskQueue_QueueType) Enum() *TaskQueue_QueueType
func (TaskQueue_QueueType) EnumDescriptor
deprecated
func (TaskQueue_QueueType) EnumDescriptor() ([]byte, []int)
Deprecated: Use TaskQueue_QueueType.Descriptor instead.
func (TaskQueue_QueueType) Number ¶
func (x TaskQueue_QueueType) Number() protoreflect.EnumNumber
func (TaskQueue_QueueType) String ¶
func (x TaskQueue_QueueType) String() string
func (TaskQueue_QueueType) Type ¶
func (TaskQueue_QueueType) Type() protoreflect.EnumType
type Tasker ¶
type TaskerMap ¶
func (*TaskerMap) Load ¶
Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.
func (*TaskerMap) LoadAndDelete ¶
LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present.
func (*TaskerMap) LoadOrStore ¶
LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored.
func (*TaskerMap) Range ¶
Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.
Range does not necessarily correspond to any consistent snapshot of the Map's contents: no key will be visited more than once, but if the value for any key is stored or deleted concurrently, Range may reflect any mapping for that key from any point during the Range call.
Range may be O(N) with the number of elements in the map even if f returns false after a constant number of calls.