Skip to content

Commit 3f0e342

Browse files
committed
Updates
1 parent 8a35824 commit 3f0e342

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

pkg/pgqueue/pgqueue.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,12 @@ func New(ctx context.Context, conn pg.PoolConn, opt ...Opt) (*Client, error) {
6868
////////////////////////////////////////////////////////////////////////////////
6969
// PUBLIC METHODS
7070

71-
func (client *Client) CreateQueue(ctx context.Context, meta schema.Queue) error {
71+
func (client *Client) CreateQueue(ctx context.Context, meta schema.Queue) (*schema.Queue, error) {
72+
var queue schema.Queue
7273
if err := client.conn.Tx(ctx, func(conn pg.Conn) error {
73-
return client.conn.Insert(ctx, meta)
74+
return client.conn.Insert(ctx, &queue, meta)
7475
}); err != nil {
75-
return err
76+
return nil, err
7677
}
77-
return nil
78+
return &queue, nil
7879
}

pkg/pgqueue/schema/queue.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ func (q Queue) Insert(bind *pg.Bind) (string, error) {
205205
}
206206

207207
// Patch
208-
func (q Queue) Patch(bind *pg.Bind) error {
208+
func (q Queue) Update(bind *pg.Bind) error {
209209
var patch []string
210210

211211
// Queue name

plugin/pg/task.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
// TYPES
1313

1414
type pgpool struct {
15-
conn pg.PoolConn
15+
pg.PoolConn
1616
}
1717

1818
var _ server.Task = (*pgpool)(nil)
@@ -21,7 +21,7 @@ var _ server.Task = (*pgpool)(nil)
2121
// LIFECYCLE
2222

2323
func taskWithConn(conn pg.PoolConn) *pgpool {
24-
return &pgpool{conn: conn}
24+
return &pgpool{conn}
2525
}
2626

2727
////////////////////////////////////////////////////////////////////////////////

plugin/pgqueue/config_test.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55
"testing"
66

77
// Packages
8+
"github.com/mutablelogic/go-server"
9+
"github.com/mutablelogic/go-server/plugin/pg"
810
pgqueue "github.com/mutablelogic/go-server/plugin/pgqueue"
911
assert "github.com/stretchr/testify/assert"
1012
)
@@ -18,9 +20,12 @@ func Test_config_001(t *testing.T) {
1820

1921
func Test_config_002(t *testing.T) {
2022
assert := assert.New(t)
21-
config := pgqueue.Config{}
22-
task, err := config.New(context.TODO())
23+
pg, err := pg.Config{}.New(context.TODO())
2324
if assert.NoError(err) {
24-
assert.NotNil(task)
25+
assert.NotNil(pg)
26+
pgqueue, err := pgqueue.Config{Pool: pg.(server.PG)}.New(context.TODO())
27+
if assert.NoError(err) {
28+
assert.NotNil(pgqueue)
29+
}
2530
}
2631
}

0 commit comments

Comments
 (0)