Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add BigQuery configuration for subscriptions #1563

Merged
merged 2 commits into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
78 changes: 75 additions & 3 deletions protos/google/pubsub/v1/pubsub.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 Google LLC
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -642,6 +642,20 @@ message Subscription {
pattern: "projects/{project}/subscriptions/{subscription}"
};

// Possible states for a subscription.
enum State {
// Default value. This value is unused.
STATE_UNSPECIFIED = 0;

// The subscription can actively receive messages
ACTIVE = 1;

// The subscription cannot receive messages because of an error with the
// resource to which it pushes messages. See the more detailed error state
// in the corresponding configuration.
RESOURCE_ERROR = 2;
}

// Required. The name of the subscription. It must have the format
// `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must
// start with a letter, and contain only letters (`[A-Za-z]`), numbers
Expand All @@ -659,10 +673,17 @@ message Subscription {
];

// If push delivery is used with this subscription, this field is
// used to configure it. An empty `pushConfig` signifies that the subscriber
// will pull and ack messages using API methods.
// used to configure it. Either `pushConfig` or `bigQueryConfig` can be set,
// but not both. If both are empty, then the subscriber will pull and ack
// messages using API methods.
PushConfig push_config = 4;

// If delivery to BigQuery is used with this subscription, this field is
// used to configure it. Either `pushConfig` or `bigQueryConfig` can be set,
// but not both. If both are empty, then the subscriber will pull and ack
// messages using API methods.
BigQueryConfig bigquery_config = 18;

// The approximate amount of time (on a best-effort basis) Pub/Sub waits for
// the subscriber to acknowledge receipt before resending the message. In the
// interval after the message is delivered and before it is acknowledged, it
Expand Down Expand Up @@ -773,6 +794,10 @@ message Subscription {
// in responses from the server; it is ignored if it is set in any requests.
google.protobuf.Duration topic_message_retention_duration = 17
[(google.api.field_behavior) = OUTPUT_ONLY];

// Output only. An output-only field indicating whether or not the subscription can receive
// messages.
State state = 19 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// A policy that specifies how Cloud Pub/Sub retries message delivery.
Expand Down Expand Up @@ -902,6 +927,53 @@ message PushConfig {
}
}

// Configuration for a BigQuery subscription.
message BigQueryConfig {
// Possible states for a BigQuery subscription.
enum State {
// Default value. This value is unused.
STATE_UNSPECIFIED = 0;

// The subscription can actively send messages to BigQuery
ACTIVE = 1;

// Cannot write to the BigQuery table because of permission denied errors.
PERMISSION_DENIED = 2;

// Cannot write to the BigQuery table because it does not exist.
NOT_FOUND = 3;

// Cannot write to the BigQuery table due to a schema mismatch.
SCHEMA_MISMATCH = 4;
}

// The name of the table to which to write data, of the form
// {projectId}:{datasetId}.{tableId}
string table = 1;

// When true, use the topic's schema as the columns to write to in BigQuery,
// if it exists.
bool use_topic_schema = 2;

// When true, write the subscription name, message_id, publish_time,
// attributes, and ordering_key to additional columns in the table. The
// subscription name, message_id, and publish_time fields are put in their own
// columns while all other message properties (other than data) are written to
// a JSON object in the attributes column.
bool write_metadata = 3;

// When true and use_topic_schema is true, any fields that are a part of the
// topic schema that are not part of the BigQuery table schema are dropped
// when writing to BigQuery. Otherwise, the schemas must be kept in sync and
// any messages with extra fields are not written and remain in the
// subscription's backlog.
bool drop_unknown_fields = 4;

// Output only. An output-only field that indicates whether or not the subscription can
// receive messages.
State state = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// A message and its corresponding acknowledgment ID.
message ReceivedMessage {
// This ID can be used to acknowledge the received message.
Expand Down
148 changes: 148 additions & 0 deletions protos/protos.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.