Documentation
¶
Overview ¶
Package neoq provides background job processing for Go applications.
Neoq's goal is to minimize the infrastructure necessary to add background job processing to Go applications. It does so by implementing queue durability with modular backends, rather than introducing a strict dependency on a particular backend such as Redis.
An in-memory and Postgres backend are provided out of the box.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New creates a new backend instance for job processing.
By default, neoq initializes memory.Backend if New() is called without a backend configuration option.
Use neoq.WithBackend to initialize different backends.
For available configuration options see config.ConfigOption.
Example ¶
ctx := context.Background()
nq, err := New(ctx, WithBackend(memory.Backend))
if err != nil {
fmt.Println("initializing a new Neoq with no params should not return an error:", err)
return
}
defer nq.Shutdown(ctx)
fmt.Println("neoq initialized with default memory backend")
Output: neoq initialized with default memory backend
Example (Postgres) ¶
ctx := context.Background()
var pgURL string
var ok bool
if pgURL, ok = os.LookupEnv("TEST_DATABASE_URL"); !ok {
fmt.Println("Please set TEST_DATABASE_URL environment variable")
return
}
nq, err := New(ctx, WithBackend(postgres.Backend), config.WithConnectionString(pgURL))
if err != nil {
fmt.Println("neoq's postgres backend failed to initialize:", err)
return
}
defer nq.Shutdown(ctx)
fmt.Println("neoq initialized with postgres backend")
Output: neoq initialized with postgres backend
func WithBackend ¶
func WithBackend(initializer config.BackendInitializer) config.Option
WithBackend configures neoq to initialize a specific backend for job processing.
Neoq provides two config.BackendInitializer that may be used with WithBackend
- pkg/github.com/acaloiaro/neoq/backends/memory.Backend
- pkg/github.com/acaloiaro/neoq/backends/postgres.Backend
Example ¶
ctx := context.Background()
nq, err := New(ctx, WithBackend(memory.Backend))
if err != nil {
fmt.Println("initializing a new Neoq with no params should not return an error:", err)
return
}
defer nq.Shutdown(ctx)
fmt.Println("neoq initialized with memory backend")
Output: neoq initialized with memory backend
Example (Postgres) ¶
ctx := context.Background()
var pgURL string
var ok bool
if pgURL, ok = os.LookupEnv("TEST_DATABASE_URL"); !ok {
fmt.Println("Please set TEST_DATABASE_URL environment variable")
return
}
nq, err := New(ctx, WithBackend(postgres.Backend), config.WithConnectionString(pgURL))
if err != nil {
fmt.Println("initializing a new Neoq with no params should not return an error:", err)
return
}
defer nq.Shutdown(ctx)
fmt.Println("neoq initialized with postgres backend")
Output: neoq initialized with postgres backend
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package backends provides concrete implementations of pkg/github.com/acaloiaro/neoq/types.Backend
|
Package backends provides concrete implementations of pkg/github.com/acaloiaro/neoq/types.Backend |
|
examples
|
|
|
add_future_postgres_job
command
|
|
|
add_job_with_custom_concurrency
command
|
|
|
add_job_with_deadline
command
|
|
|
add_periodic_jobs
command
|
|
|
add_postgres_job
command
|
|
|
start_processing_jobs
command
|
|
