-
Notifications
You must be signed in to change notification settings - Fork 3
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: AIP-214 – Resource expiration #39
Open
lukesneeringer
wants to merge
2
commits into
main
Choose a base branch
from
aip-214
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Resource expiration | ||
|
||
Customers often want to provide the time that a given resource or attribute of | ||
a resource is no longer useful or should be deleted. Currently we recommend | ||
that customers do this by specifying an exact "expiration time" into a | ||
`expire_time` field with a timestamp type; however, this adds additional strain | ||
on the user when they want to specify a relative time offset until expiration | ||
rather than a specific time until expiration. | ||
|
||
Furthermore, the world understands the concept of a "time-to-live", often | ||
abbreviated to TTL, but the typical format of this field (an integer, measured | ||
in seconds) results in a sub-par experience when using an auto-generated client | ||
library. | ||
|
||
## Guidance | ||
|
||
Services wishing to convey an expiration **must** rely on a timestamp field | ||
called `expire_time`. Services wishing to allow a relative expiration time | ||
**must** define a `oneof` called `expiration` (or `{something}_expiration`) | ||
containing both the `expire_time` field and a separate [duration][aip-142] | ||
field called `ttl`, the latter marked as input only: | ||
|
||
{% tab proto %} | ||
|
||
{% sample 'expiry.proto', 'message Book' %} | ||
|
||
{% tab oas %} | ||
|
||
{% sample 'expiry.oas.yaml', 'schema' %} | ||
|
||
{% endtabs %} | ||
|
||
Services **must** always return the expiration time in the `expire_time` field | ||
and leave the `ttl` field blank when retrieving the resource. | ||
|
||
Services that rely on the specific semantics of a "time to live" (e.g., DNS | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update AIP-142 similarly re: canonical unit being {days, hours, minutes, seconds}. |
||
which must represent the TTL as an integer) **may** use an `int64 ttl` field | ||
(and **should** provide an [aip.dev/not-precedent][aip-200] comment in this | ||
case). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
id: 214 | ||
state: approved | ||
created: 2018-06-19 | ||
placement: | ||
category: design-patterns | ||
order: 120 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
openapi: 3.0.3 | ||
info: | ||
title: Library | ||
version: 1.0.0 | ||
paths: {} | ||
components: | ||
schemas: | ||
Book: | ||
description: This book will self-destruct. | ||
type: object | ||
properties: | ||
name: | ||
type: string | ||
description: | | ||
The name of the book. | ||
Format: publishers/{publisher}/books/{book} | ||
oneOf: | ||
- type: object | ||
properties: | ||
expireTime: | ||
type: string | ||
format: date-time | ||
description: | | ||
Timestamp in UTC of when this resource is considered expired. | ||
- type: object | ||
properties: | ||
ttlSeconds: | ||
type: integer | ||
description: | | ||
The TTL for this resource in seconds. | ||
When this value is passed as input it is returned as the equivalent | ||
expireTime on output. | ||
writeOnly: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2021 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
syntax = "proto3"; | ||
|
||
import "google/api/field_behavior.proto"; | ||
import "google/api/resource.proto"; | ||
import "google/protobuf/duration.proto"; | ||
import "google/protobuf/timestamp.proto"; | ||
|
||
// This book will self-destruct. | ||
message Book { | ||
option (google.api.resource) = { | ||
type: "library.googleapis.com/Book" | ||
pattern: "publishers/{publisher}/books/{book}" | ||
}; | ||
|
||
// The name of the resource; the format is: ... | ||
string name = 1; | ||
|
||
oneof expiration { | ||
// Timestamp in UTC of when this resource is considered expired. | ||
// This is *always* provided on output, regardless of what was sent | ||
// on input. | ||
google.protobuf.Timestamp expire_time = 2; | ||
|
||
// Input only. The TTL for this resource. | ||
google.protobuf.Duration ttl = 3 | ||
[(google.api.field_behavior) = INPUT_ONLY]; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.