mirror of
https://github.com/hibiken/asynq.git
synced 2024-12-26 07:42:17 +08:00
[ci skip] Fix comments
This commit is contained in:
parent
6dd4c688f4
commit
7af69c8d3c
24
asynq.go
24
asynq.go
@ -11,7 +11,7 @@ import (
|
|||||||
"github.com/go-redis/redis/v7"
|
"github.com/go-redis/redis/v7"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Task represents a task to be performed.
|
// Task represents a unit of work to be performed.
|
||||||
type Task struct {
|
type Task struct {
|
||||||
// Type indicates the type of task to be performed.
|
// Type indicates the type of task to be performed.
|
||||||
Type string
|
Type string
|
||||||
@ -20,10 +20,9 @@ type Task struct {
|
|||||||
Payload Payload
|
Payload Payload
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTask returns a new Task. The typename and payload argument set Type
|
// NewTask returns a new Task given a type name and payload data.
|
||||||
// and Payload field respectively.
|
|
||||||
//
|
//
|
||||||
// The payload must be serializable to JSON.
|
// The payload values must be serializable.
|
||||||
func NewTask(typename string, payload map[string]interface{}) *Task {
|
func NewTask(typename string, payload map[string]interface{}) *Task {
|
||||||
return &Task{
|
return &Task{
|
||||||
Type: typename,
|
Type: typename,
|
||||||
@ -31,13 +30,11 @@ func NewTask(typename string, payload map[string]interface{}) *Task {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// RedisConnOpt is a discriminated union of redis-client-option types.
|
// RedisConnOpt is a discriminated union of types that represent Redis connection configuration option.
|
||||||
//
|
//
|
||||||
// RedisConnOpt represents a sum of following types:
|
// RedisConnOpt represents a sum of following types:
|
||||||
//
|
//
|
||||||
// RedisClientOpt | *RedisClientOpt | RedisFailoverClientOpt | *RedisFailoverClientOpt
|
// RedisClientOpt | *RedisClientOpt | RedisFailoverClientOpt | *RedisFailoverClientOpt
|
||||||
//
|
|
||||||
// Passing unexpected type to a RedisConnOpt variable can cause panic.
|
|
||||||
type RedisConnOpt interface{}
|
type RedisConnOpt interface{}
|
||||||
|
|
||||||
// RedisClientOpt is used to create a redis client that connects
|
// RedisClientOpt is used to create a redis client that connects
|
||||||
@ -53,7 +50,7 @@ type RedisClientOpt struct {
|
|||||||
// Redis server password.
|
// Redis server password.
|
||||||
Password string
|
Password string
|
||||||
|
|
||||||
// Redis DB to select after connecting to the server.
|
// Redis DB to select after connecting to a server.
|
||||||
// See: https://redis.io/commands/select.
|
// See: https://redis.io/commands/select.
|
||||||
DB int
|
DB int
|
||||||
|
|
||||||
@ -61,13 +58,13 @@ type RedisClientOpt struct {
|
|||||||
// Default is 10 connections per every CPU as reported by runtime.NumCPU.
|
// Default is 10 connections per every CPU as reported by runtime.NumCPU.
|
||||||
PoolSize int
|
PoolSize int
|
||||||
|
|
||||||
// TLS Config used to connect to the server.
|
// TLS Config used to connect to a server.
|
||||||
// TLS will be negotiated only if this field is set.
|
// TLS will be negotiated only if this field is set.
|
||||||
TLSConfig *tls.Config
|
TLSConfig *tls.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
// RedisFailoverClientOpt is used to creates a redis client that talks
|
// RedisFailoverClientOpt is used to creates a redis client that talks
|
||||||
// to redis sentinels for service discovery and has automatic failover
|
// to redis sentinels for service discovery and has an automatic failover
|
||||||
// capability.
|
// capability.
|
||||||
type RedisFailoverClientOpt struct {
|
type RedisFailoverClientOpt struct {
|
||||||
// Redis master name that monitored by sentinels.
|
// Redis master name that monitored by sentinels.
|
||||||
@ -84,7 +81,7 @@ type RedisFailoverClientOpt struct {
|
|||||||
// Redis server password.
|
// Redis server password.
|
||||||
Password string
|
Password string
|
||||||
|
|
||||||
// Redis DB to select after connecting to the server.
|
// Redis DB to select after connecting to a server.
|
||||||
// See: https://redis.io/commands/select.
|
// See: https://redis.io/commands/select.
|
||||||
DB int
|
DB int
|
||||||
|
|
||||||
@ -92,11 +89,14 @@ type RedisFailoverClientOpt struct {
|
|||||||
// Default is 10 connections per every CPU as reported by runtime.NumCPU.
|
// Default is 10 connections per every CPU as reported by runtime.NumCPU.
|
||||||
PoolSize int
|
PoolSize int
|
||||||
|
|
||||||
// TLS Config used to connect to the server.
|
// TLS Config used to connect to a server.
|
||||||
// TLS will be negotiated only if this field is set.
|
// TLS will be negotiated only if this field is set.
|
||||||
TLSConfig *tls.Config
|
TLSConfig *tls.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// createRedisClient returns a redis client given a redis connection configuration.
|
||||||
|
//
|
||||||
|
// Passing an unexpected type as a RedisConnOpt argument will cause panic.
|
||||||
func createRedisClient(r RedisConnOpt) *redis.Client {
|
func createRedisClient(r RedisConnOpt) *redis.Client {
|
||||||
switch r := r.(type) {
|
switch r := r.(type) {
|
||||||
case *RedisClientOpt:
|
case *RedisClientOpt:
|
||||||
|
Loading…
Reference in New Issue
Block a user