Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Side by Side Diff: common/gcloud/gcps/ackbuffer/ack.go

Issue 1610993002: LogDog: Add collector service implementation. (Closed) Base URL: https://github.com/luci/luci-go@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package ackbuffer
6
7 import (
8 "github.com/luci/luci-go/common/gcloud/gcps"
9 "golang.org/x/net/context"
10 )
11
12 // Acknowledger sends ACKs to a Pub/Sub interface.
13 //
14 // gcps.PubSub naturally implements this interface.
15 type Acknowledger interface {
dnj (Google) 2016/01/21 04:36:24 These changes allow better interoperability betwee
16 // Ack acknowledges one or more Pub/Sub message ACK IDs.
17 Ack(ctx context.Context, ackIDs ...string) error
18
19 // AckBatchSize returns the maximum number of ACKs that can be sent at a time.
20 AckBatchSize() int
21 }
22
23 type gcpsACK struct {
24 ps gcps.PubSub
25 sub gcps.Subscription
26 batch int
27 }
28
29 // NewACK creates a Acknowledger instance from a gcps.PubSub implementation.
30 //
31 // If batch is <= 0, the maximum ACK batch size will be used.
32 func NewACK(ps gcps.PubSub, s gcps.Subscription, batch int) Acknowledger {
33 if batch <= 0 {
34 batch = gcps.MaxMessageAckPerRequest
35 }
36
37 return &gcpsACK{
38 ps: ps,
39 sub: s,
40 batch: batch,
41 }
42 }
43
44 func (a *gcpsACK) Ack(c context.Context, ackIDs ...string) error {
45 return a.ps.Ack(c, a.sub, ackIDs...)
46 }
47
48 func (a *gcpsACK) AckBatchSize() int {
49 return a.batch
50 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698