mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2026-04-23 10:39:45 -05:00
42 lines
880 B
Go
42 lines
880 B
Go
package dispatcher
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
|
|
"github.com/hatchet-dev/hatchet/internal/msgqueue"
|
|
"github.com/hatchet-dev/hatchet/internal/services/dispatcher/contracts"
|
|
)
|
|
|
|
type subscribedWorker struct {
|
|
// stream is the server side of the RPC stream
|
|
stream contracts.Dispatcher_ListenServer
|
|
|
|
// finished is used to signal closure of a client subscribing goroutine
|
|
finished chan<- bool
|
|
|
|
sendLock *TimeoutLock
|
|
|
|
workerId uuid.UUID
|
|
|
|
pubBuffer *msgqueue.MQPubBuffer
|
|
}
|
|
|
|
func newSubscribedWorker(
|
|
stream contracts.Dispatcher_ListenServer,
|
|
fin chan<- bool,
|
|
workerId uuid.UUID,
|
|
maxLockAcquisitionTime time.Duration,
|
|
pubBuffer *msgqueue.MQPubBuffer,
|
|
) *subscribedWorker {
|
|
lock := NewTimeoutLock(maxLockAcquisitionTime)
|
|
return &subscribedWorker{
|
|
stream: stream,
|
|
finished: fin,
|
|
workerId: workerId,
|
|
pubBuffer: pubBuffer,
|
|
sendLock: lock,
|
|
}
|
|
}
|