Attribute Name | Type | Note |
---|---|---|
id |
String | Required. The ID of the event. A CloudEvent is uniquely identified with its source and id . |
source |
String (URI-reference) | Required. The source of the event. |
specversion |
String | Required. The version of CloudEvents Specification the Cloud Event uses. |
type |
String | Required. The type of the event. |
datacontentencoding |
String (RFC 2045 Section 6.1) | Optional. The encoding of |
This file contains hidden or 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
apiVersion: apiextensions.k8s.io/v1 | |
kind: CustomResourceDefinition | |
metadata: | |
annotations: | |
"helm.sh/resource-policy": keep | |
labels: | |
app: istio-pilot | |
chart: istio | |
heritage: Tiller | |
release: istio |
This file contains hidden or 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
public class StreamingJob { | |
public static void main(String[] args) throws Exception { | |
// Set up the streaming execution environment | |
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); | |
env.enableCheckpointing(4000); | |
// Set up a Cloud Pub/Sub topic as input | |
// deserializer controls how Apache Flink deserializes the message |
This file contains hidden or 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
// A wrapper for rejecting dead-lettered events. | |
module.exports = functions.https.onRequest(async (req, res) => { | |
try { | |
return await fulfill(req, res); | |
} catch (err) { | |
console.log(err.message); | |
// Stripe webhook events are delivered via HTTP. Here it is wrapped in | |
// a Cloud Event and rejected to DLQ via Cloud Pub/Sub. | |
const stripeWebhookEventRejected = utils.createStripeWebhookEventRejectedEvent(SOURCE, req.headers, req.body, err.message); | |
await utils.publishEvent(pubSubClient, DLQ, stripeWebhookEventRejected); |
This file contains hidden or 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
const tracing = require('@opencensus/nodejs'); | |
const { StackdriverTraceExporter } = require('@opencensus/exporter-stackdriver'); | |
const exporter = new StackdriverTraceExporter({projectId: "YOUR-GCP-PROJECT"}); | |
const tracer = tracing.registerExporter(exporter).start({ samplingRate: 1 }).tracer(); | |
function A () { | |
let traceId; | |
tracer.startRootSpan({ name: 'A' }, rootSpan => { |
This file contains hidden or 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
const {Logging} = require('@google-cloud/logging'); | |
const logging = new Logging(); | |
// const logName = 'customLog'; | |
// const resourceType = 'cloud_function'; | |
// const labels = { | |
// 'source': 'fulfillment', | |
// 'orderId': 'myOrderId' | |
// }; |
This file contains hidden or 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
async function fulfill (req, res) { | |
... | |
// Rejects stale events. | |
utils.checkForExpiredEvents('POSIX', paymentIntent.created, EVENT_MAX_AGE); | |
// Checks if the event is duplicated. | |
await utils.guaranteeExactlyOnceDelivery(firestoreClient, EVENT_COLLECTION, paymentIntent.id, JSON.stringify(paymentIntent)); | |
... | |
} |
This file contains hidden or 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
from mypackage import Basic | |
# Attributes id and time will be auto-populated | |
# If not specified, attributes source, type, and specversion use their respective default values | |
event = Basic(data = 'Hello World!') | |
event_json_str = event.to_JSON() |
This file contains hidden or 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
import datetime | |
import json | |
import uuid | |
event = {} | |
event['id'] = str(uuid.uuid4()) | |
event['source'] = 'my-event-source' | |
event[type] = 'my-event-type' | |
event['specversion'] = '0.3' | |
event['time'] = datetime.datetime.utcnow().isoformat('T') + 'Z' |
This file contains hidden or 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
events: | |
# Define an event type, basic | |
basic: | |
attributes: | |
# Set up an attribute id which is auto-poulated with UUIDv4 string | |
id: | |
type: string | |
format: UUIDv4 | |
auto: true | |
# Set up an attribute source with a default value |