Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
66d8352502 |
@@ -27,6 +27,8 @@ type Client struct {
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc
|
||||
running bool
|
||||
|
||||
leaseSeconds int
|
||||
}
|
||||
|
||||
type TaskFilter struct {
|
||||
@@ -115,6 +117,10 @@ func New(baseURL string, ApplicationID string, WorkerId string) *Client {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) SetLeaseSeconds(s int) {
|
||||
c.leaseSeconds = s
|
||||
}
|
||||
|
||||
// Enqueue adds a new task.
|
||||
func (c *Client) enqueue(ctx context.Context, request *EnqueueRequest) (*Task, error) {
|
||||
request.ApplicationId = c.ApplicationID
|
||||
@@ -290,9 +296,15 @@ func (c *Client) pollLoop() {
|
||||
}
|
||||
|
||||
func (c *Client) pollServer() {
|
||||
|
||||
leaseSeconds := c.leaseSeconds
|
||||
if leaseSeconds == 0 {
|
||||
leaseSeconds = 60
|
||||
}
|
||||
|
||||
task, ok, err := c.pop(c.ctx, &PopRequest{
|
||||
WorkerId: c.WorkerID,
|
||||
LeaseSeconds: 60,
|
||||
LeaseSeconds: leaseSeconds,
|
||||
Filter: &TaskFilter{
|
||||
ApplicationId: c.ApplicationID,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user