Skip to content

Commit ab763ff

Browse files
committed
use struct{}{} for notification chans, because they use zero space
1 parent 991f060 commit ab763ff

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

dbos/queue.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ type queueRunner struct {
145145
workflowQueueRegistry map[string]WorkflowQueue
146146

147147
// Channel to signal completion back to the DBOS context
148-
completionChan chan bool
148+
completionChan chan struct{}
149149
}
150150

151151
func newQueueRunner() *queueRunner {
@@ -158,7 +158,7 @@ func newQueueRunner() *queueRunner {
158158
jitterMin: 0.95,
159159
jitterMax: 1.05,
160160
workflowQueueRegistry: make(map[string]WorkflowQueue),
161-
completionChan: make(chan bool),
161+
completionChan: make(chan struct{}),
162162
}
163163
}
164164

@@ -252,7 +252,7 @@ func (qr *queueRunner) run(ctx *dbosContext) {
252252
select {
253253
case <-ctx.Done():
254254
ctx.logger.Info("Queue runner stopping due to context cancellation", "cause", context.Cause(ctx))
255-
qr.completionChan <- true
255+
qr.completionChan <- struct{}{}
256256
return
257257
case <-time.After(sleepDuration):
258258
// Continue to next iteration

dbos/system_database.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ type systemDatabase interface {
6565
type sysDB struct {
6666
pool *pgxpool.Pool
6767
notificationListenerConnection *pgconn.PgConn
68-
notificationLoopDone chan bool
68+
notificationLoopDone chan struct{}
6969
notificationsMap *sync.Map
7070
logger *slog.Logger
7171
launched bool
@@ -104,7 +104,6 @@ func createDatabaseIfNotExists(ctx context.Context, databaseURL string, logger *
104104
return newInitializationError(fmt.Sprintf("failed to check if database exists: %v", err))
105105
}
106106
if !exists {
107-
// TODO: validate db name
108107
createSQL := fmt.Sprintf("CREATE DATABASE %s", pgx.Identifier{dbName}.Sanitize())
109108
_, err = conn.Exec(ctx, createSQL)
110109
if err != nil {
@@ -225,7 +224,7 @@ func newSystemDatabase(ctx context.Context, databaseURL string, logger *slog.Log
225224
pool: pool,
226225
notificationListenerConnection: notificationListenerConnection,
227226
notificationsMap: notificationsMap,
228-
notificationLoopDone: make(chan bool),
227+
notificationLoopDone: make(chan struct{}),
229228
logger: logger,
230229
}, nil
231230
}
@@ -1363,7 +1362,7 @@ func (s *sysDB) sleep(ctx context.Context, duration time.Duration) (time.Duratio
13631362

13641363
func (s *sysDB) notificationListenerLoop(ctx context.Context) {
13651364
defer func() {
1366-
s.notificationLoopDone <- true
1365+
s.notificationLoopDone <- struct{}{}
13671366
}()
13681367

13691368
s.logger.Info("DBOS: Starting notification listener loop")

0 commit comments

Comments
 (0)