google-cloud-logging 0.21.0 → 0.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.yardopts +10 -0
- data/LICENSE +201 -0
- data/README.md +115 -0
- data/lib/google/cloud/logging.rb +3 -1
- data/lib/google/cloud/logging/logger.rb +1 -0
- data/lib/google/cloud/logging/middleware.rb +82 -27
- data/lib/google/cloud/logging/rails.rb +12 -6
- data/lib/google/cloud/logging/v2/config_service_v2_api.rb +12 -12
- data/lib/google/cloud/logging/v2/doc/google/api/monitored_resource.rb +81 -0
- data/lib/google/cloud/logging/v2/doc/google/logging/type/http_request.rb +80 -0
- data/lib/google/cloud/logging/v2/doc/google/logging/v2/log_entry.rb +99 -0
- data/lib/google/cloud/logging/v2/doc/google/logging/v2/logging.rb +148 -0
- data/lib/google/cloud/logging/v2/doc/google/logging/v2/logging_config.rb +150 -0
- data/lib/google/cloud/logging/v2/doc/google/logging/v2/logging_metrics.rb +126 -0
- data/lib/google/cloud/logging/v2/doc/google/protobuf/any.rb +104 -0
- data/lib/google/cloud/logging/v2/doc/google/protobuf/duration.rb +71 -0
- data/lib/google/cloud/logging/v2/doc/google/protobuf/timestamp.rb +83 -0
- data/lib/google/cloud/logging/v2/logging_service_v2_api.rb +19 -24
- data/lib/google/cloud/logging/v2/metrics_service_v2_api.rb +12 -12
- data/lib/google/cloud/logging/version.rb +1 -1
- metadata +17 -5
@@ -0,0 +1,150 @@
|
|
1
|
+
# Copyright 2016 Google Inc. All rights reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Google
|
16
|
+
module Logging
|
17
|
+
module V2
|
18
|
+
# Describes a sink used to export log entries outside Stackdriver Logging.
|
19
|
+
# @!attribute [rw] name
|
20
|
+
# @return [String]
|
21
|
+
# Required. The client-assigned sink identifier, unique within the
|
22
|
+
# project. Example: +"my-syslog-errors-to-pubsub"+. Sink identifiers are
|
23
|
+
# limited to 1000 characters and can include only the following characters:
|
24
|
+
# +A-Z+, +a-z+, +0-9+, and the special characters +_-.+. The maximum length
|
25
|
+
# of the name is 100 characters.
|
26
|
+
# @!attribute [rw] destination
|
27
|
+
# @return [String]
|
28
|
+
# Required. The export destination. See
|
29
|
+
# {Exporting Logs With Sinks}[https://cloud.google.com/logging/docs/api/tasks/exporting-logs].
|
30
|
+
# Examples:
|
31
|
+
#
|
32
|
+
# "storage.googleapis.com/my-gcs-bucket"
|
33
|
+
# "bigquery.googleapis.com/projects/my-project-id/datasets/my-dataset"
|
34
|
+
# "pubsub.googleapis.com/projects/my-project/topics/my-topic"
|
35
|
+
# @!attribute [rw] filter
|
36
|
+
# @return [String]
|
37
|
+
# Optional. An {advanced logs filter}[https://cloud.google.com/logging/docs/view/advanced_filters].
|
38
|
+
# Only log entries matching the filter are exported. The filter
|
39
|
+
# must be consistent with the log entry format specified by the
|
40
|
+
# +outputVersionFormat+ parameter, regardless of the format of the
|
41
|
+
# log entry that was originally written to Stackdriver Logging.
|
42
|
+
# Example filter (V2 format):
|
43
|
+
#
|
44
|
+
# logName=projects/my-projectid/logs/syslog AND severity>=ERROR
|
45
|
+
# @!attribute [rw] output_version_format
|
46
|
+
# @return [Google::Logging::V2::LogSink::VersionFormat]
|
47
|
+
# Optional. The log entry version to use for this sink's exported log
|
48
|
+
# entries. This version does not have to correspond to the version of the
|
49
|
+
# log entry that was written to Stackdriver Logging. If omitted, the
|
50
|
+
# v2 format is used.
|
51
|
+
# @!attribute [rw] writer_identity
|
52
|
+
# @return [String]
|
53
|
+
# Output only. The iam identity to which the destination needs to grant write
|
54
|
+
# access. This may be a service account or a group.
|
55
|
+
# Examples (Do not assume these specific values):
|
56
|
+
# "serviceAccount:cloud-logs@system.gserviceaccount.com"
|
57
|
+
# "group:cloud-logs@google.com"
|
58
|
+
#
|
59
|
+
# For GCS destinations, the role "roles/owner" is required on the bucket
|
60
|
+
# For Cloud Pubsub destinations, the role "roles/pubsub.publisher" is
|
61
|
+
# required on the topic
|
62
|
+
# For BigQuery, the role "roles/editor" is required on the dataset
|
63
|
+
class LogSink
|
64
|
+
# Available log entry formats. Log entries can be written to Cloud
|
65
|
+
# Logging in either format and can be exported in either format.
|
66
|
+
# Version 2 is the preferred format.
|
67
|
+
module VersionFormat
|
68
|
+
# An unspecified version format will default to V2.
|
69
|
+
VERSION_FORMAT_UNSPECIFIED = 0
|
70
|
+
|
71
|
+
# +LogEntry+ version 2 format.
|
72
|
+
V2 = 1
|
73
|
+
|
74
|
+
# +LogEntry+ version 1 format.
|
75
|
+
V1 = 2
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# The parameters to +ListSinks+.
|
80
|
+
# @!attribute [rw] parent
|
81
|
+
# @return [String]
|
82
|
+
# Required. The cloud resource containing the sinks.
|
83
|
+
# Example: +"projects/my-logging-project"+.
|
84
|
+
# @!attribute [rw] page_token
|
85
|
+
# @return [String]
|
86
|
+
# Optional. If present, then retrieve the next batch of results from the
|
87
|
+
# preceding call to this method. +pageToken+ must be the value of
|
88
|
+
# +nextPageToken+ from the previous response. The values of other method
|
89
|
+
# parameters should be identical to those in the previous call.
|
90
|
+
# @!attribute [rw] page_size
|
91
|
+
# @return [Integer]
|
92
|
+
# Optional. The maximum number of results to return from this request.
|
93
|
+
# Non-positive values are ignored. The presence of +nextPageToken+ in the
|
94
|
+
# response indicates that more results might be available.
|
95
|
+
class ListSinksRequest; end
|
96
|
+
|
97
|
+
# Result returned from +ListSinks+.
|
98
|
+
# @!attribute [rw] sinks
|
99
|
+
# @return [Array<Google::Logging::V2::LogSink>]
|
100
|
+
# A list of sinks.
|
101
|
+
# @!attribute [rw] next_page_token
|
102
|
+
# @return [String]
|
103
|
+
# If there might be more results than appear in this response, then
|
104
|
+
# +nextPageToken+ is included. To get the next set of results, call the same
|
105
|
+
# method again using the value of +nextPageToken+ as +pageToken+.
|
106
|
+
class ListSinksResponse; end
|
107
|
+
|
108
|
+
# The parameters to +GetSink+.
|
109
|
+
# @!attribute [rw] sink_name
|
110
|
+
# @return [String]
|
111
|
+
# Required. The resource name of the sink to return.
|
112
|
+
# Example: +"projects/my-project-id/sinks/my-sink-id"+.
|
113
|
+
class GetSinkRequest; end
|
114
|
+
|
115
|
+
# The parameters to +CreateSink+.
|
116
|
+
# @!attribute [rw] parent
|
117
|
+
# @return [String]
|
118
|
+
# Required. The resource in which to create the sink.
|
119
|
+
# Example: +"projects/my-project-id"+.
|
120
|
+
# The new sink must be provided in the request.
|
121
|
+
# @!attribute [rw] sink
|
122
|
+
# @return [Google::Logging::V2::LogSink]
|
123
|
+
# Required. The new sink, whose +name+ parameter is a sink identifier that
|
124
|
+
# is not already in use.
|
125
|
+
class CreateSinkRequest; end
|
126
|
+
|
127
|
+
# The parameters to +UpdateSink+.
|
128
|
+
# @!attribute [rw] sink_name
|
129
|
+
# @return [String]
|
130
|
+
# Required. The resource name of the sink to update, including the parent
|
131
|
+
# resource and the sink identifier. If the sink does not exist, this method
|
132
|
+
# creates the sink. Example: +"projects/my-project-id/sinks/my-sink-id"+.
|
133
|
+
# @!attribute [rw] sink
|
134
|
+
# @return [Google::Logging::V2::LogSink]
|
135
|
+
# Required. The updated sink, whose name is the same identifier that appears
|
136
|
+
# as part of +sinkName+. If +sinkName+ does not exist, then
|
137
|
+
# this method creates a new sink.
|
138
|
+
class UpdateSinkRequest; end
|
139
|
+
|
140
|
+
# The parameters to +DeleteSink+.
|
141
|
+
# @!attribute [rw] sink_name
|
142
|
+
# @return [String]
|
143
|
+
# Required. The resource name of the sink to delete, including the parent
|
144
|
+
# resource and the sink identifier. Example:
|
145
|
+
# +"projects/my-project-id/sinks/my-sink-id"+. It is an error if the sink
|
146
|
+
# does not exist.
|
147
|
+
class DeleteSinkRequest; end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
# Copyright 2016 Google Inc. All rights reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Google
|
16
|
+
module Logging
|
17
|
+
module V2
|
18
|
+
# Describes a logs-based metric. The value of the metric is the
|
19
|
+
# number of log entries that match a logs filter.
|
20
|
+
# @!attribute [rw] name
|
21
|
+
# @return [String]
|
22
|
+
# Required. The client-assigned metric identifier. Example:
|
23
|
+
# +"severe_errors"+. Metric identifiers are limited to 100
|
24
|
+
# characters and can include only the following characters: +A-Z+,
|
25
|
+
# +a-z+, +0-9+, and the special characters +_-.,+!*',()%/+. The
|
26
|
+
# forward-slash character (+/+) denotes a hierarchy of name pieces,
|
27
|
+
# and it cannot be the first character of the name. The '%' character
|
28
|
+
# is used to URL encode unsafe and reserved characters and must be
|
29
|
+
# followed by two hexadecimal digits according to RFC 1738.
|
30
|
+
# @!attribute [rw] description
|
31
|
+
# @return [String]
|
32
|
+
# Optional. A description of this metric, which is used in documentation.
|
33
|
+
# @!attribute [rw] filter
|
34
|
+
# @return [String]
|
35
|
+
# Required. An {advanced logs filter}[https://cloud.google.com/logging/docs/view/advanced_filters].
|
36
|
+
# Example: +"resource.type=gae_app AND severity>=ERROR"+.
|
37
|
+
# @!attribute [rw] version
|
38
|
+
# @return [Google::Logging::V2::LogMetric::ApiVersion]
|
39
|
+
# Output only. The API version that created or updated this metric.
|
40
|
+
# The version also dictates the syntax of the filter expression. When a value
|
41
|
+
# for this field is missing, the default value of V2 should be assumed.
|
42
|
+
class LogMetric
|
43
|
+
# Stackdriver Logging API version.
|
44
|
+
module ApiVersion
|
45
|
+
# Stackdriver Logging API v2.
|
46
|
+
V2 = 0
|
47
|
+
|
48
|
+
# Stackdriver Logging API v1.
|
49
|
+
V1 = 1
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# The parameters to ListLogMetrics.
|
54
|
+
# @!attribute [rw] parent
|
55
|
+
# @return [String]
|
56
|
+
# Required. The resource name containing the metrics.
|
57
|
+
# Example: +"projects/my-project-id"+.
|
58
|
+
# @!attribute [rw] page_token
|
59
|
+
# @return [String]
|
60
|
+
# Optional. If present, then retrieve the next batch of results from the
|
61
|
+
# preceding call to this method. +pageToken+ must be the value of
|
62
|
+
# +nextPageToken+ from the previous response. The values of other method
|
63
|
+
# parameters should be identical to those in the previous call.
|
64
|
+
# @!attribute [rw] page_size
|
65
|
+
# @return [Integer]
|
66
|
+
# Optional. The maximum number of results to return from this request.
|
67
|
+
# Non-positive values are ignored. The presence of +nextPageToken+ in the
|
68
|
+
# response indicates that more results might be available.
|
69
|
+
class ListLogMetricsRequest; end
|
70
|
+
|
71
|
+
# Result returned from ListLogMetrics.
|
72
|
+
# @!attribute [rw] metrics
|
73
|
+
# @return [Array<Google::Logging::V2::LogMetric>]
|
74
|
+
# A list of logs-based metrics.
|
75
|
+
# @!attribute [rw] next_page_token
|
76
|
+
# @return [String]
|
77
|
+
# If there might be more results than appear in this response, then
|
78
|
+
# +nextPageToken+ is included. To get the next set of results, call this
|
79
|
+
# method again using the value of +nextPageToken+ as +pageToken+.
|
80
|
+
class ListLogMetricsResponse; end
|
81
|
+
|
82
|
+
# The parameters to GetLogMetric.
|
83
|
+
# @!attribute [rw] metric_name
|
84
|
+
# @return [String]
|
85
|
+
# The resource name of the desired metric.
|
86
|
+
# Example: +"projects/my-project-id/metrics/my-metric-id"+.
|
87
|
+
class GetLogMetricRequest; end
|
88
|
+
|
89
|
+
# The parameters to CreateLogMetric.
|
90
|
+
# @!attribute [rw] parent
|
91
|
+
# @return [String]
|
92
|
+
# The resource name of the project in which to create the metric.
|
93
|
+
# Example: +"projects/my-project-id"+.
|
94
|
+
#
|
95
|
+
# The new metric must be provided in the request.
|
96
|
+
# @!attribute [rw] metric
|
97
|
+
# @return [Google::Logging::V2::LogMetric]
|
98
|
+
# The new logs-based metric, which must not have an identifier that
|
99
|
+
# already exists.
|
100
|
+
class CreateLogMetricRequest; end
|
101
|
+
|
102
|
+
# The parameters to UpdateLogMetric.
|
103
|
+
# @!attribute [rw] metric_name
|
104
|
+
# @return [String]
|
105
|
+
# The resource name of the metric to update.
|
106
|
+
# Example: +"projects/my-project-id/metrics/my-metric-id"+.
|
107
|
+
#
|
108
|
+
# The updated metric must be provided in the request and have the
|
109
|
+
# same identifier that is specified in +metricName+.
|
110
|
+
# If the metric does not exist, it is created.
|
111
|
+
# @!attribute [rw] metric
|
112
|
+
# @return [Google::Logging::V2::LogMetric]
|
113
|
+
# The updated metric, whose name must be the same as the
|
114
|
+
# metric identifier in +metricName+. If +metricName+ does not
|
115
|
+
# exist, then a new metric is created.
|
116
|
+
class UpdateLogMetricRequest; end
|
117
|
+
|
118
|
+
# The parameters to DeleteLogMetric.
|
119
|
+
# @!attribute [rw] metric_name
|
120
|
+
# @return [String]
|
121
|
+
# The resource name of the metric to delete.
|
122
|
+
# Example: +"projects/my-project-id/metrics/my-metric-id"+.
|
123
|
+
class DeleteLogMetricRequest; end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# Copyright 2016 Google Inc. All rights reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Google
|
16
|
+
module Protobuf
|
17
|
+
# +Any+ contains an arbitrary serialized protocol buffer message along with a
|
18
|
+
# URL that describes the type of the serialized message.
|
19
|
+
#
|
20
|
+
# Protobuf library provides support to pack/unpack Any values in the form
|
21
|
+
# of utility functions or additional generated methods of the Any type.
|
22
|
+
#
|
23
|
+
# Example 1: Pack and unpack a message in C++.
|
24
|
+
#
|
25
|
+
# Foo foo = ...;
|
26
|
+
# Any any;
|
27
|
+
# any.PackFrom(foo);
|
28
|
+
# ...
|
29
|
+
# if (any.UnpackTo(&foo)) {
|
30
|
+
# ...
|
31
|
+
# }
|
32
|
+
#
|
33
|
+
# Example 2: Pack and unpack a message in Java.
|
34
|
+
#
|
35
|
+
# Foo foo = ...;
|
36
|
+
# Any any = Any.pack(foo);
|
37
|
+
# ...
|
38
|
+
# if (any.is(Foo.class)) {
|
39
|
+
# foo = any.unpack(Foo.class);
|
40
|
+
# }
|
41
|
+
#
|
42
|
+
# The pack methods provided by protobuf library will by default use
|
43
|
+
# 'type.googleapis.com/full.type.name' as the type URL and the unpack
|
44
|
+
# methods only use the fully qualified type name after the last '/'
|
45
|
+
# in the type URL, for example "foo.bar.com/x/y.z" will yield type
|
46
|
+
# name "y.z".
|
47
|
+
#
|
48
|
+
#
|
49
|
+
# = JSON
|
50
|
+
#
|
51
|
+
# The JSON representation of an +Any+ value uses the regular
|
52
|
+
# representation of the deserialized, embedded message, with an
|
53
|
+
# additional field +@type+ which contains the type URL. Example:
|
54
|
+
#
|
55
|
+
# package google.profile;
|
56
|
+
# message Person {
|
57
|
+
# string first_name = 1;
|
58
|
+
# string last_name = 2;
|
59
|
+
# }
|
60
|
+
#
|
61
|
+
# {
|
62
|
+
# "@type": "type.googleapis.com/google.profile.Person",
|
63
|
+
# "firstName": <string>,
|
64
|
+
# "lastName": <string>
|
65
|
+
# }
|
66
|
+
#
|
67
|
+
# If the embedded message type is well-known and has a custom JSON
|
68
|
+
# representation, that representation will be embedded adding a field
|
69
|
+
# +value+ which holds the custom JSON in addition to the +@type+
|
70
|
+
# field. Example (for message Google::Protobuf::Duration):
|
71
|
+
#
|
72
|
+
# {
|
73
|
+
# "@type": "type.googleapis.com/google.protobuf.Duration",
|
74
|
+
# "value": "1.212s"
|
75
|
+
# }
|
76
|
+
# @!attribute [rw] type_url
|
77
|
+
# @return [String]
|
78
|
+
# A URL/resource name whose content describes the type of the
|
79
|
+
# serialized protocol buffer message.
|
80
|
+
#
|
81
|
+
# For URLs which use the schema +http+, +https+, or no schema, the
|
82
|
+
# following restrictions and interpretations apply:
|
83
|
+
#
|
84
|
+
# * If no schema is provided, +https+ is assumed.
|
85
|
+
# * The last segment of the URL's path must represent the fully
|
86
|
+
# qualified name of the type (as in +path/google.protobuf.Duration+).
|
87
|
+
# The name should be in a canonical form (e.g., leading "." is
|
88
|
+
# not accepted).
|
89
|
+
# * An HTTP GET on the URL must yield a Google::Protobuf::Type
|
90
|
+
# value in binary format, or produce an error.
|
91
|
+
# * Applications are allowed to cache lookup results based on the
|
92
|
+
# URL, or have them precompiled into a binary to avoid any
|
93
|
+
# lookup. Therefore, binary compatibility needs to be preserved
|
94
|
+
# on changes to types. (Use versioned type names to manage
|
95
|
+
# breaking changes.)
|
96
|
+
#
|
97
|
+
# Schemas other than +http+, +https+ (or the empty schema) might be
|
98
|
+
# used with implementation specific semantics.
|
99
|
+
# @!attribute [rw] value
|
100
|
+
# @return [String]
|
101
|
+
# Must be a valid serialized protocol buffer of the above specified type.
|
102
|
+
class Any; end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# Copyright 2016 Google Inc. All rights reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Google
|
16
|
+
module Protobuf
|
17
|
+
# A Duration represents a signed, fixed-length span of time represented
|
18
|
+
# as a count of seconds and fractions of seconds at nanosecond
|
19
|
+
# resolution. It is independent of any calendar and concepts like "day"
|
20
|
+
# or "month". It is related to Timestamp in that the difference between
|
21
|
+
# two Timestamp values is a Duration and it can be added or subtracted
|
22
|
+
# from a Timestamp. Range is approximately +-10,000 years.
|
23
|
+
#
|
24
|
+
# Example 1: Compute Duration from two Timestamps in pseudo code.
|
25
|
+
#
|
26
|
+
# Timestamp start = ...;
|
27
|
+
# Timestamp end = ...;
|
28
|
+
# Duration duration = ...;
|
29
|
+
#
|
30
|
+
# duration.seconds = end.seconds - start.seconds;
|
31
|
+
# duration.nanos = end.nanos - start.nanos;
|
32
|
+
#
|
33
|
+
# if (duration.seconds < 0 && duration.nanos > 0) {
|
34
|
+
# duration.seconds += 1;
|
35
|
+
# duration.nanos -= 1000000000;
|
36
|
+
# } else if (durations.seconds > 0 && duration.nanos < 0) {
|
37
|
+
# duration.seconds -= 1;
|
38
|
+
# duration.nanos += 1000000000;
|
39
|
+
# }
|
40
|
+
#
|
41
|
+
# Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
|
42
|
+
#
|
43
|
+
# Timestamp start = ...;
|
44
|
+
# Duration duration = ...;
|
45
|
+
# Timestamp end = ...;
|
46
|
+
#
|
47
|
+
# end.seconds = start.seconds + duration.seconds;
|
48
|
+
# end.nanos = start.nanos + duration.nanos;
|
49
|
+
#
|
50
|
+
# if (end.nanos < 0) {
|
51
|
+
# end.seconds -= 1;
|
52
|
+
# end.nanos += 1000000000;
|
53
|
+
# } else if (end.nanos >= 1000000000) {
|
54
|
+
# end.seconds += 1;
|
55
|
+
# end.nanos -= 1000000000;
|
56
|
+
# }
|
57
|
+
# @!attribute [rw] seconds
|
58
|
+
# @return [Integer]
|
59
|
+
# Signed seconds of the span of time. Must be from -315,576,000,000
|
60
|
+
# to +315,576,000,000 inclusive.
|
61
|
+
# @!attribute [rw] nanos
|
62
|
+
# @return [Integer]
|
63
|
+
# Signed fractions of a second at nanosecond resolution of the span
|
64
|
+
# of time. Durations less than one second are represented with a 0
|
65
|
+
# +seconds+ field and a positive or negative +nanos+ field. For durations
|
66
|
+
# of one second or more, a non-zero value for the +nanos+ field must be
|
67
|
+
# of the same sign as the +seconds+ field. Must be from -999,999,999
|
68
|
+
# to +999,999,999 inclusive.
|
69
|
+
class Duration; end
|
70
|
+
end
|
71
|
+
end
|