-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
break: Rename types.Backend -> neoq.Neoq
- Loading branch information
Showing
15 changed files
with
158 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
SHELL := /bin/bash | ||
GOLANGCI_LINT_VERSION ?= v1.51.1 | ||
|
||
all: fmt vet mod | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Package backends provides concrete implementations of [pkg/github.com/acaloiaro/neoq/types.Backend] | ||
// Package backends provides concrete implementations of [pkg/github.com/acaloiaro/neoq/neoq.Neoq] | ||
// | ||
// These backends provide the bulk of Neoq's functionality. | ||
package backends |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,12 +9,11 @@ import ( | |
"sync" | ||
"time" | ||
|
||
"github.com/acaloiaro/neoq/config" | ||
"github.com/acaloiaro/neoq" | ||
"github.com/acaloiaro/neoq/handler" | ||
"github.com/acaloiaro/neoq/internal" | ||
"github.com/acaloiaro/neoq/jobs" | ||
"github.com/acaloiaro/neoq/logging" | ||
"github.com/acaloiaro/neoq/types" | ||
"github.com/golang-migrate/migrate/v4" | ||
_ "github.com/golang-migrate/migrate/v4/database/postgres" // nolint: revive | ||
"github.com/golang-migrate/migrate/v4/source/iofs" | ||
|
@@ -69,8 +68,8 @@ var ( | |
|
||
// PgBackend is a Postgres-based Neoq backend | ||
type PgBackend struct { | ||
types.Backend | ||
config *config.Config | ||
neoq.Neoq | ||
config *neoq.Config | ||
logger logging.Logger | ||
cron *cron.Cron | ||
mu *sync.RWMutex // mutex to protect mutating state on a pgWorker | ||
|
@@ -84,7 +83,7 @@ type PgBackend struct { | |
// | ||
// If the database does not yet exist, Neoq will attempt to create the database and related tables by default. | ||
// | ||
// Backend requires that one of the [config.ConfigOption] is [WithConnectionString] | ||
// Backend requires that one of the [neoq.ConfigOption] is [WithConnectionString] | ||
// | ||
// Connection strings may be a URL or DSN-style connection strings. The connection string supports multiple | ||
// options detailed below. | ||
|
@@ -104,10 +103,13 @@ type PgBackend struct { | |
// # Example URL | ||
// | ||
// postgres://worker:[email protected]:5432/mydb?sslmode=verify-ca&pool_max_conns=10 | ||
func Backend(ctx context.Context, opts ...config.Option) (pb types.Backend, err error) { | ||
func Backend(ctx context.Context, opts ...neoq.ConfigOption) (pb neoq.Neoq, err error) { | ||
cfg := neoq.NewConfig() | ||
cfg.IdleTransactionTimeout = neoq.DefaultIdleTxTimeout | ||
|
||
p := &PgBackend{ | ||
mu: &sync.RWMutex{}, | ||
config: config.New(), | ||
config: cfg, | ||
handlers: make(map[string]handler.Handler), | ||
futureJobs: make(map[string]time.Time), | ||
cron: cron.New(), | ||
|
@@ -164,8 +166,8 @@ func Backend(ctx context.Context, opts ...config.Option) (pb types.Backend, err | |
} | ||
|
||
// WithConnectionString configures neoq postgres backend to use the specified connection string when connecting to a backend | ||
func WithConnectionString(connectionString string) config.Option { | ||
return func(c *config.Config) { | ||
func WithConnectionString(connectionString string) neoq.ConfigOption { | ||
return func(c *neoq.Config) { | ||
c.ConnectionString = connectionString | ||
} | ||
} | ||
|
@@ -175,8 +177,8 @@ func WithConnectionString(connectionString string) config.Option { | |
// The timeout is the number of milliseconds that a transaction may sit idle before postgres terminates the | ||
// transaction's underlying connection. The timeout should be longer than your longest job takes to complete. If set | ||
// too short, job state will become unpredictable, e.g. retry counts may become incorrect. | ||
func WithTransactionTimeout(txTimeout int) config.Option { | ||
return func(c *config.Config) { | ||
func WithTransactionTimeout(txTimeout int) neoq.ConfigOption { | ||
return func(c *neoq.Config) { | ||
c.IdleTransactionTimeout = txTimeout | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ func main() { | |
ctx := context.Background() | ||
nq, err := neoq.New(ctx, | ||
neoq.WithBackend(postgres.Backend), | ||
postgres.WithConnectionString("postgres://postgres:[email protected]:5432/neoq"), | ||
postgres.WithConnectionString("postgres://postgres:[email protected]:5432/neoq?sslmode=disable"), | ||
postgres.WithTransactionTimeout(1000), // nolint: mnd, gomnd | ||
) | ||
if err != nil { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,11 +12,11 @@ import ( | |
) | ||
|
||
func main() { | ||
var done = make(chan bool, 1) | ||
done := make(chan bool, 1) | ||
const queue = "foobar" | ||
ctx := context.Background() | ||
nq, err := neoq.New(ctx, | ||
postgres.WithConnectionString("postgres://postgres:[email protected]:5432/neoq"), | ||
postgres.WithConnectionString("postgres://postgres:[email protected]:5432/neoq?sslmode=disable"), | ||
neoq.WithBackend(postgres.Backend), | ||
) | ||
if err != nil { | ||
|
Oops, something went wrong.