Documentation ¶
Overview ¶
Neoq does not aim to be the _fastest_ background job processor. It aims to be _fast_, _reliable_, and demand a _minimal infrastructure footprint_.
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), postgres.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), postgres.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
func WithJobCheckInterval ¶
WithJobCheckInterval configures the duration of time between checking for future jobs
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
|
|