-
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
14 changed files
with
153 additions
and
158 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
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,10 @@ 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) { | ||
p := &PgBackend{ | ||
mu: &sync.RWMutex{}, | ||
config: config.New(), | ||
config: neoq.NewConfig(), | ||
handlers: make(map[string]handler.Handler), | ||
futureJobs: make(map[string]time.Time), | ||
cron: cron.New(), | ||
|
@@ -164,8 +163,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 +174,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.