blob: ac896933201b553ed9992db76757a8b27b5532b0 [file] [log] [blame]
Chen Wang405392c2015-02-03 10:28:39 -08001// This file will be moved to a new location.
Chen Wangb532ef82015-02-02 10:45:17 -08002
Craig Tillerad1fd3a2015-02-16 12:23:04 -08003// Copyright 2015, Google Inc.
4// All rights reserved.
Craig Tillerce5021b2015-02-18 09:25:21 -08005//
Craig Tillerad1fd3a2015-02-16 12:23:04 -08006// Redistribution and use in source and binary forms, with or without
7// modification, are permitted provided that the following conditions are
8// met:
Craig Tillerce5021b2015-02-18 09:25:21 -08009//
Craig Tillerad1fd3a2015-02-16 12:23:04 -080010// * Redistributions of source code must retain the above copyright
11// notice, this list of conditions and the following disclaimer.
12// * Redistributions in binary form must reproduce the above
13// copyright notice, this list of conditions and the following disclaimer
14// in the documentation and/or other materials provided with the
15// distribution.
16// * Neither the name of Google Inc. nor the names of its
17// contributors may be used to endorse or promote products derived from
18// this software without specific prior written permission.
Craig Tillerce5021b2015-02-18 09:25:21 -080019//
Craig Tillerad1fd3a2015-02-16 12:23:04 -080020// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32
Chen Wang86af8cf2015-01-21 18:05:40 -080033// Specification of the Pubsub API.
34
35syntax = "proto2";
36
Chen wang84232512015-02-12 17:29:18 -080037import "examples/pubsub/empty.proto";
38import "examples/pubsub/label.proto";
Chen Wang86af8cf2015-01-21 18:05:40 -080039
40package tech.pubsub;
41
42// -----------------------------------------------------------------------------
43// Overview of the Pubsub API
44// -----------------------------------------------------------------------------
45
46// This file describes an API for a Pubsub system. This system provides a
47// reliable many-to-many communication mechanism between independently written
48// publishers and subscribers where the publisher publishes messages to "topics"
49// and each subscriber creates a "subscription" and consumes messages from it.
50//
51// (a) The pubsub system maintains bindings between topics and subscriptions.
52// (b) A publisher publishes messages into a topic.
53// (c) The pubsub system delivers messages from topics into relevant
54// subscriptions.
55// (d) A subscriber receives pending messages from its subscription and
56// acknowledges or nacks each one to the pubsub system.
57// (e) The pubsub system removes acknowledged messages from that subscription.
58
59// -----------------------------------------------------------------------------
60// Data Model
61// -----------------------------------------------------------------------------
62
63// The data model consists of the following:
64//
65// * Topic: A topic is a resource to which messages are published by publishers.
66// Topics are named, and the name of the topic is unique within the pubsub
67// system.
68//
69// * Subscription: A subscription records the subscriber's interest in a topic.
70// It can optionally include a query to select a subset of interesting
71// messages. The pubsub system maintains a logical cursor tracking the
72// matching messages which still need to be delivered and acked so that
73// they can retried as needed. The set of messages that have not been
74// acknowledged is called the subscription backlog.
75//
76// * Message: A message is a unit of data that flows in the system. It contains
77// opaque data from the publisher along with its labels.
78//
79// * Message Labels (optional): A set of opaque key, value pairs assigned
80// by the publisher which the subscriber can use for filtering out messages
81// in the topic. For example, a label with key "foo.com/device_type" and
82// value "mobile" may be added for messages that are only relevant for a
83// mobile subscriber; a subscriber on a phone may decide to create a
84// subscription only for messages that have this label.
85
86// -----------------------------------------------------------------------------
87// Publisher Flow
88// -----------------------------------------------------------------------------
89
90// A publisher publishes messages to the topic using the Publish request:
91//
92// PubsubMessage message;
93// message.set_data("....");
94// Label label;
95// label.set_key("foo.com/key1");
96// label.set_str_value("value1");
97// message.add_label(label);
98// PublishRequest request;
99// request.set_topic("topicName");
100// request.set_message(message);
101// PublisherService.Publish(request);
102
103// -----------------------------------------------------------------------------
104// Subscriber Flow
105// -----------------------------------------------------------------------------
106
107// The subscriber part of the API is richer than the publisher part and has a
108// number of concepts w.r.t. subscription creation and monitoring:
109//
110// (1) A subscriber creates a subscription using the CreateSubscription call.
111// It may specify an optional "query" to indicate that it wants to receive
112// only messages with a certain set of labels using the label query syntax.
113// It may also specify an optional truncation policy to indicate when old
114// messages from the subcription can be removed.
115//
116// (2) A subscriber receives messages in one of two ways: via push or pull.
117//
118// (a) To receive messages via push, the PushConfig field must be specified in
119// the Subscription parameter when creating a subscription. The PushConfig
120// specifies an endpoint at which the subscriber must expose the
121// PushEndpointService. Messages are received via the HandlePubsubEvent
122// method. The push subscriber responds to the HandlePubsubEvent method
123// with a result code that indicates one of three things: Ack (the message
124// has been successfully processed and the Pubsub system may delete it),
125// Nack (the message has been rejected, the Pubsub system should resend it
126// at a later time), or Push-Back (this is a Nack with the additional
127// semantics that the subscriber is overloaded and the pubsub system should
128// back off on the rate at which it is invoking HandlePubsubEvent). The
129// endpoint may be a load balancer for better scalability.
130//
131// (b) To receive messages via pull a subscriber calls the Pull method on the
132// SubscriberService to get messages from the subscription. For each
133// individual message, the subscriber may use the ack_id received in the
134// PullResponse to Ack the message, Nack the message, or modify the ack
135// deadline with ModifyAckDeadline. See the
136// Subscription.ack_deadline_seconds field documentation for details on the
137// ack deadline behavior.
138//
139// Note: Messages may be consumed in parallel by multiple subscribers making
140// Pull calls to the same subscription; this will result in the set of
141// messages from the subscription being shared and each subscriber
142// receiving a subset of the messages.
143//
144// (4) The subscriber can explicitly truncate the current subscription.
145//
146// (5) "Truncated" events are delivered when a subscription is
147// truncated, whether due to the subscription's truncation policy
148// or an explicit request from the subscriber.
149//
150// Subscription creation:
151//
152// Subscription subscription;
153// subscription.set_topic("topicName");
154// subscription.set_name("subscriptionName");
155// subscription.push_config().set_push_endpoint("machinename:8888");
156// SubscriberService.CreateSubscription(subscription);
157//
158// Consuming messages via push:
159//
160// TODO(eschapira): Add HTTP push example.
161//
162// The port 'machinename:8888' must be bound to a stubby server that implements
163// the PushEndpointService with the following method:
164//
165// int HandlePubsubEvent(PubsubEvent event) {
166// if (event.subscription().equals("subscriptionName")) {
167// if (event.has_message()) {
168// Process(event.message().data());
169// } else if (event.truncated()) {
170// ProcessTruncatedEvent();
171// }
172// }
173// return OK; // This return code implies an acknowledgment
174// }
175//
176// Consuming messages via pull:
177//
178// The subscription must be created without setting the push_config field.
179//
180// PullRequest pull_request;
181// pull_request.set_subscription("subscriptionName");
182// pull_request.set_return_immediately(false);
183// while (true) {
184// PullResponse pull_response;
185// if (SubscriberService.Pull(pull_request, pull_response) == OK) {
186// PubsubEvent event = pull_response.pubsub_event();
187// if (event.has_message()) {
188// Process(event.message().data());
189// } else if (event.truncated()) {
190// ProcessTruncatedEvent();
191// }
192// AcknowledgeRequest ack_request;
193// ackRequest.set_subscription("subscriptionName");
194// ackRequest.set_ack_id(pull_response.ack_id());
195// SubscriberService.Acknowledge(ack_request);
196// }
197// }
198
199// -----------------------------------------------------------------------------
200// Reliability Semantics
201// -----------------------------------------------------------------------------
202
203// When a subscriber successfully creates a subscription using
204// Subscriber.CreateSubscription, it establishes a "subscription point" with
205// respect to that subscription - the subscriber is guaranteed to receive any
206// message published after this subscription point that matches the
207// subscription's query. Note that messages published before the Subscription
208// point may or may not be delivered.
209//
210// If the system truncates the subscription according to the specified
211// truncation policy, the system delivers a subscription status event with the
212// "truncated" field set to true. We refer to such events as "truncation
213// events". A truncation event:
214//
215// * Informs the subscriber that part of the subscription messages have been
216// discarded. The subscriber may want to recover from the message loss, e.g.,
217// by resyncing its state with its backend.
218// * Establishes a new subscription point, i.e., the subscriber is guaranteed to
219// receive all changes published after the trunction event is received (or
220// until another truncation event is received).
221//
222// Note that messages are not delivered in any particular order by the pubsub
223// system. Furthermore, the system guarantees at-least-once delivery
224// of each message or truncation events until acked.
225
226// -----------------------------------------------------------------------------
227// Deletion
228// -----------------------------------------------------------------------------
229
230// Both topics and subscriptions may be deleted. Deletion of a topic implies
231// deletion of all attached subscriptions.
232//
233// When a subscription is deleted directly by calling DeleteSubscription, all
234// messages are immediately dropped. If it is a pull subscriber, future pull
235// requests will return NOT_FOUND.
236//
237// When a topic is deleted all corresponding subscriptions are immediately
238// deleted, and subscribers experience the same behavior as directly deleting
239// the subscription.
240
241// -----------------------------------------------------------------------------
242// The Publisher service and its protos.
243// -----------------------------------------------------------------------------
244
245// The service that an application uses to manipulate topics, and to send
246// messages to a topic.
247service PublisherService {
248
249 // Creates the given topic with the given name.
250 rpc CreateTopic(Topic) returns (Topic) {
251 }
252
253 // Adds a message to the topic. Returns NOT_FOUND if the topic does not
254 // exist.
255 // (-- For different error code values returned via Stubby, see
256 // util/task/codes.proto. --)
257 rpc Publish(PublishRequest) returns (proto2.Empty) {
258 }
259
260 // Adds one or more messages to the topic. Returns NOT_FOUND if the topic does
261 // not exist.
262 rpc PublishBatch(PublishBatchRequest) returns (PublishBatchResponse) {
263 }
264
265 // Gets the configuration of a topic. Since the topic only has the name
266 // attribute, this method is only useful to check the existence of a topic.
267 // If other attributes are added in the future, they will be returned here.
268 rpc GetTopic(GetTopicRequest) returns (Topic) {
269 }
270
271 // Lists matching topics.
272 rpc ListTopics(ListTopicsRequest) returns (ListTopicsResponse) {
273 }
274
275 // Deletes the topic with the given name. All subscriptions to this topic
276 // are also deleted. Returns NOT_FOUND if the topic does not exist.
277 // After a topic is deleted, a new topic may be created with the same name.
278 rpc DeleteTopic(DeleteTopicRequest) returns (proto2.Empty) {
279 }
280}
281
282// A topic resource.
283message Topic {
284 // Name of the topic.
285 optional string name = 1;
286}
287
288// A message data and its labels.
289message PubsubMessage {
290 // The message payload.
291 optional bytes data = 1;
292
293 // Optional list of labels for this message. Keys in this collection must
294 // be unique.
295 //(-- TODO(eschapira): Define how key namespace may be scoped to the topic.--)
296 repeated tech.label.Label label = 2;
297
298 // ID of this message assigned by the server at publication time. Guaranteed
299 // to be unique within the topic. This value may be read by a subscriber
300 // that receives a PubsubMessage via a Pull call or a push delivery. It must
301 // not be populated by a publisher in a Publish call.
302 optional string message_id = 3;
303}
304
305// Request for the GetTopic method.
306message GetTopicRequest {
307 // The name of the topic to get.
308 optional string topic = 1;
309}
310
311// Request for the Publish method.
312message PublishRequest {
313 // The message in the request will be published on this topic.
314 optional string topic = 1;
315
316 // The message to publish.
317 optional PubsubMessage message = 2;
318}
319
320// Request for the PublishBatch method.
321message PublishBatchRequest {
322 // The messages in the request will be published on this topic.
323 optional string topic = 1;
324
325 // The messages to publish.
326 repeated PubsubMessage messages = 2;
327}
328
329// Response for the PublishBatch method.
330message PublishBatchResponse {
331 // The server-assigned ID of each published message, in the same order as
332 // the messages in the request. IDs are guaranteed to be unique within
333 // the topic.
334 repeated string message_ids = 1;
335}
336
337// Request for the ListTopics method.
338message ListTopicsRequest {
339 // A valid label query expression.
340 // (-- Which labels are required or supported is implementation-specific. --)
341 optional string query = 1;
342
343 // Maximum number of topics to return.
344 // (-- If not specified or <= 0, the implementation will select a reasonable
345 // value. --)
346 optional int32 max_results = 2;
347
348 // The value obtained in the last <code>ListTopicsResponse</code>
349 // for continuation.
350 optional string page_token = 3;
351
352}
353
354// Response for the ListTopics method.
355message ListTopicsResponse {
356 // The resulting topics.
357 repeated Topic topic = 1;
358
359 // If not empty, indicates that there are more topics that match the request,
360 // and this value should be passed to the next <code>ListTopicsRequest</code>
361 // to continue.
362 optional string next_page_token = 2;
363}
364
365// Request for the Delete method.
366message DeleteTopicRequest {
367 // Name of the topic to delete.
368 optional string topic = 1;
369}
370
371// -----------------------------------------------------------------------------
372// The Subscriber service and its protos.
373// -----------------------------------------------------------------------------
374
375// The service that an application uses to manipulate subscriptions and to
376// consume messages from a subscription via the pull method.
377service SubscriberService {
378
379 // Creates a subscription on a given topic for a given subscriber.
380 // If the subscription already exists, returns ALREADY_EXISTS.
381 // If the corresponding topic doesn't exist, returns NOT_FOUND.
382 //
383 // If the name is not provided in the request, the server will assign a random
384 // name for this subscription on the same project as the topic.
385 rpc CreateSubscription(Subscription) returns (Subscription) {
386 }
387
388 // Gets the configuration details of a subscription.
389 rpc GetSubscription(GetSubscriptionRequest) returns (Subscription) {
390 }
391
392 // Lists matching subscriptions.
393 rpc ListSubscriptions(ListSubscriptionsRequest)
394 returns (ListSubscriptionsResponse) {
395 }
396
397 // Deletes an existing subscription. All pending messages in the subscription
398 // are immediately dropped. Calls to Pull after deletion will return
399 // NOT_FOUND.
400 rpc DeleteSubscription(DeleteSubscriptionRequest) returns (proto2.Empty) {
401 }
402
403 // Removes all the pending messages in the subscription and releases the
404 // storage associated with them. Results in a truncation event to be sent to
405 // the subscriber. Messages added after this call returns are stored in the
406 // subscription as before.
407 rpc TruncateSubscription(TruncateSubscriptionRequest) returns (proto2.Empty) {
408 }
409
410 //
411 // Push subscriber calls.
412 //
413
414 // Modifies the <code>PushConfig</code> for a specified subscription.
415 // This method can be used to suspend the flow of messages to an endpoint
416 // by clearing the <code>PushConfig</code> field in the request. Messages
417 // will be accumulated for delivery even if no push configuration is
418 // defined or while the configuration is modified.
419 rpc ModifyPushConfig(ModifyPushConfigRequest) returns (proto2.Empty) {
420 }
421
422 //
423 // Pull Subscriber calls
424 //
425
426 // Pulls a single message from the server.
427 // If return_immediately is true, and no messages are available in the
428 // subscription, this method returns FAILED_PRECONDITION. The system is free
429 // to return an UNAVAILABLE error if no messages are available in a
430 // reasonable amount of time (to reduce system load).
431 rpc Pull(PullRequest) returns (PullResponse) {
432 }
433
434 // Pulls messages from the server. Returns an empty list if there are no
435 // messages available in the backlog. The system is free to return UNAVAILABLE
436 // if there are too many pull requests outstanding for the given subscription.
437 rpc PullBatch(PullBatchRequest) returns (PullBatchResponse) {
438 }
439
440 // Modifies the Ack deadline for a message received from a pull request.
441 rpc ModifyAckDeadline(ModifyAckDeadlineRequest) returns (proto2.Empty) {
442 }
443
444 // Acknowledges a particular received message: the Pub/Sub system can remove
445 // the given message from the subscription. Acknowledging a message whose
446 // Ack deadline has expired may succeed, but the message could have been
447 // already redelivered. Acknowledging a message more than once will not
448 // result in an error. This is only used for messages received via pull.
449 rpc Acknowledge(AcknowledgeRequest) returns (proto2.Empty) {
450 }
451
452 // Refuses processing a particular received message. The system will
453 // redeliver this message to some consumer of the subscription at some
454 // future time. This is only used for messages received via pull.
455 rpc Nack(NackRequest) returns (proto2.Empty) {
456 }
457}
458
459// A subscription resource.
460message Subscription {
461 // Name of the subscription.
462 optional string name = 1;
463
464 // The name of the topic from which this subscription is receiving messages.
465 optional string topic = 2;
466
467 // If <code>query</code> is non-empty, only messages on the subscriber's
468 // topic whose labels match the query will be returned. Otherwise all
469 // messages on the topic will be returned.
470 // (-- The query syntax is described in tech/label/proto/label_query.proto --)
471 optional string query = 3;
472
473 // The subscriber may specify requirements for truncating unacknowledged
474 // subscription entries. The system will honor the
475 // <code>CreateSubscription</code> request only if it can meet these
476 // requirements. If this field is not specified, messages are never truncated
477 // by the system.
478 optional TruncationPolicy truncation_policy = 4;
479
480 // Specifies which messages can be truncated by the system.
481 message TruncationPolicy {
482 oneof policy {
483 // If <code>max_bytes</code> is specified, the system is allowed to drop
484 // old messages to keep the combined size of stored messages under
485 // <code>max_bytes</code>. This is a hint; the system may keep more than
486 // this many bytes, but will make a best effort to keep the size from
487 // growing much beyond this parameter.
488 int64 max_bytes = 1;
489
490 // If <code>max_age_seconds</code> is specified, the system is allowed to
491 // drop messages that have been stored for at least this many seconds.
492 // This is a hint; the system may keep these messages, but will make a
493 // best effort to remove them when their maximum age is reached.
494 int64 max_age_seconds = 2;
495 }
496 }
497
498 // If push delivery is used with this subscription, this field is
499 // used to configure it.
500 optional PushConfig push_config = 5;
501
502 // For either push or pull delivery, the value is the maximum time after a
503 // subscriber receives a message before the subscriber should acknowledge or
504 // Nack the message. If the Ack deadline for a message passes without an
505 // Ack or a Nack, the Pub/Sub system will eventually redeliver the message.
506 // If a subscriber acknowledges after the deadline, the Pub/Sub system may
507 // accept the Ack, but it is possible that the message has been already
508 // delivered again. Multiple Acks to the message are allowed and will
509 // succeed.
510 //
511 // For push delivery, this value is used to set the request timeout for
512 // the call to the push endpoint.
513 //
514 // For pull delivery, this value is used as the initial value for the Ack
515 // deadline. It may be overridden for a specific pull request (message) with
516 // <code>ModifyAckDeadline</code>.
517 // While a message is outstanding (i.e. it has been delivered to a pull
518 // subscriber and the subscriber has not yet Acked or Nacked), the Pub/Sub
519 // system will not deliver that message to another pull subscriber
520 // (on a best-effort basis).
521 optional int32 ack_deadline_seconds = 6;
522
523 // If this parameter is set to n, the system is allowed to (but not required
524 // to) delete the subscription when at least n seconds have elapsed since the
525 // client presence was detected. (Presence is detected through any
526 // interaction using the subscription ID, including Pull(), Get(), or
527 // acknowledging a message.)
528 //
529 // If this parameter is not set, the subscription will stay live until
530 // explicitly deleted.
531 //
532 // Clients can detect such garbage collection when a Get call or a Pull call
533 // (for pull subscribers only) returns NOT_FOUND.
534 optional int64 garbage_collect_seconds = 7;
535}
536
537// Configuration for a push delivery endpoint.
538message PushConfig {
539 // A URL locating the endpoint to which messages should be pushed.
540 // For example, a Webhook endpoint might use "https://example.com/push".
541 // (-- An Android application might use "gcm:<REGID>", where <REGID> is a
542 // GCM registration id allocated for pushing messages to the application. --)
543 optional string push_endpoint = 1;
544}
545
546// An event indicating a received message or truncation event.
547message PubsubEvent {
548 // The subscription that received the event.
549 optional string subscription = 1;
550
551 oneof type {
552 // A received message.
553 PubsubMessage message = 2;
554
555 // Indicates that this subscription has been truncated.
556 bool truncated = 3;
557
558 // Indicates that this subscription has been deleted. (Note that pull
559 // subscribers will always receive NOT_FOUND in response in their pull
560 // request on the subscription, rather than seeing this boolean.)
561 bool deleted = 4;
562 }
563}
564
565// Request for the GetSubscription method.
566message GetSubscriptionRequest {
567 // The name of the subscription to get.
568 optional string subscription = 1;
569}
570
571// Request for the ListSubscriptions method.
572message ListSubscriptionsRequest {
573 // A valid label query expression.
574 // (-- Which labels are required or supported is implementation-specific.
575 // TODO(eschapira): This method must support to query by topic. We must
576 // define the key URI for the "topic" label. --)
577 optional string query = 1;
578
579 // Maximum number of subscriptions to return.
580 // (-- If not specified or <= 0, the implementation will select a reasonable
581 // value. --)
582 optional int32 max_results = 3;
583
584 // The value obtained in the last <code>ListSubscriptionsResponse</code>
585 // for continuation.
586 optional string page_token = 4;
587}
588
589// Response for the ListSubscriptions method.
590message ListSubscriptionsResponse {
591 // The subscriptions that match the request.
592 repeated Subscription subscription = 1;
593
594 // If not empty, indicates that there are more subscriptions that match the
595 // request and this value should be passed to the next
596 // <code>ListSubscriptionsRequest</code> to continue.
597 optional string next_page_token = 2;
598}
599
600// Request for the TruncateSubscription method.
601message TruncateSubscriptionRequest {
602 // The subscription that is being truncated.
603 optional string subscription = 1;
604}
605
606// Request for the DeleteSubscription method.
607message DeleteSubscriptionRequest {
608 // The subscription to delete.
609 optional string subscription = 1;
610}
611
612// Request for the ModifyPushConfig method.
613message ModifyPushConfigRequest {
614 // The name of the subscription.
615 optional string subscription = 1;
616
617 // An empty <code>push_config</code> indicates that the Pub/Sub system should
618 // pause pushing messages from the given subscription.
619 optional PushConfig push_config = 2;
620}
621
622// -----------------------------------------------------------------------------
623// The protos used by a pull subscriber.
624// -----------------------------------------------------------------------------
625
626// Request for the Pull method.
627message PullRequest {
628 // The subscription from which a message should be pulled.
629 optional string subscription = 1;
630
631 // If this is specified as true the system will respond immediately even if
632 // it is not able to return a message in the Pull response. Otherwise the
633 // system is allowed to wait until at least one message is available rather
634 // than returning FAILED_PRECONDITION. The client may cancel the request if
635 // it does not wish to wait any longer for the response.
636 optional bool return_immediately = 2;
637}
638
639// Either a <code>PubsubMessage</code> or a truncation event. One of these two
640// must be populated.
641message PullResponse {
642 // This ID must be used to acknowledge the received event or message.
643 optional string ack_id = 1;
644
645 // A pubsub message or truncation event.
646 optional PubsubEvent pubsub_event = 2;
647}
648
649// Request for the PullBatch method.
650message PullBatchRequest {
651 // The subscription from which messages should be pulled.
652 optional string subscription = 1;
653
654 // If this is specified as true the system will respond immediately even if
655 // it is not able to return a message in the Pull response. Otherwise the
656 // system is allowed to wait until at least one message is available rather
657 // than returning no messages. The client may cancel the request if it does
658 // not wish to wait any longer for the response.
659 optional bool return_immediately = 2;
660
661 // The maximum number of PubsubEvents returned for this request. The Pub/Sub
662 // system may return fewer than the number of events specified.
663 optional int32 max_events = 3;
664}
665
666// Response for the PullBatch method.
667message PullBatchResponse {
668
669 // Received Pub/Sub messages or status events. The Pub/Sub system will return
670 // zero messages if there are no more messages available in the backlog. The
671 // Pub/Sub system may return fewer than the max_events requested even if
672 // there are more messages available in the backlog.
673 repeated PullResponse pull_responses = 2;
674}
675
676// Request for the ModifyAckDeadline method.
677message ModifyAckDeadlineRequest {
678 // The name of the subscription from which messages are being pulled.
679 optional string subscription = 1;
680
681 // The acknowledgment ID.
682 optional string ack_id = 2;
683
684 // The new Ack deadline. Must be >= 0.
685 optional int32 ack_deadline_seconds = 3;
686}
687
688// Request for the Acknowledge method.
689message AcknowledgeRequest {
690 // The subscription whose message is being acknowledged.
691 optional string subscription = 1;
692
693 // The acknowledgment ID for the message being acknowledged. This was
694 // returned by the Pub/Sub system in the Pull response.
695 repeated string ack_id = 2;
696}
697
698// Request for the Nack method.
699message NackRequest {
700 // The subscription whose message is being Nacked.
701 optional string subscription = 1;
702
703 // The acknowledgment ID for the message being refused. This was returned by
704 // the Pub/Sub system in the Pull response.
705 repeated string ack_id = 2;
706}
707
708// -----------------------------------------------------------------------------
709// The service and protos used by a push subscriber.
710// -----------------------------------------------------------------------------
711
712// The service that a subscriber uses to handle messages sent via push
713// delivery.
714// This service is not currently exported for HTTP clients.
715// TODO(eschapira): Explain HTTP subscribers.
716service PushEndpointService {
717 // Sends a <code>PubsubMessage</code> or a subscription status event to a
718 // push endpoint.
719 // The push endpoint responds with an empty message and a code from
720 // util/task/codes.proto. The following codes have a particular meaning to the
721 // Pub/Sub system:
722 // OK - This is interpreted by Pub/Sub as Ack.
723 // ABORTED - This is intepreted by Pub/Sub as a Nack, without implying
724 // pushback for congestion control. The Pub/Sub system will
725 // retry this message at a later time.
726 // UNAVAILABLE - This is intepreted by Pub/Sub as a Nack, with the additional
727 // semantics of push-back. The Pub/Sub system will use an AIMD
728 // congestion control algorithm to backoff the rate of sending
729 // messages from this subscription.
730 // Any other code, or a failure to respond, will be interpreted in the same
731 // way as ABORTED; i.e. the system will retry the message at a later time to
732 // ensure reliable delivery.
733 rpc HandlePubsubEvent(PubsubEvent) returns (proto2.Empty);
734}