Project: CloudEvents (App Definition and Development / Streaming & Messaging)
File: 2018-02-22-CloudEvents.pdf

Broker or API GatewayFunctioninvokerFunction runtimeEvent APIEvent Protocol (HTTP , AMQP , Kafka, ..)
Event Message(body+envelope)
PlatformServicesInternal protocol(out of scope)EXTERNAL EVENTSINTERNAL EVENTSCloud Events Problem Scope and Relations
2
3
1Per language
Event-Mapper/ OrchestrationMapping APIMapping SpecSource Service(out of scope for now)functiongetLambdaEventSource(event){if(event.Records&&event.Records[0].cf)return'isCloudfront';if(event.configRuleId&&event.configRuleName&&event.configRuleArn)return'isAwsConfig';if(event.Records&&(event.Records[0].eventSource==='aws:codecommit'))return'isCodeCommit';if(event.authorizationToken==="incoming-client-token")return'isApiGatewayAuthorizer';if(event.StackId&&event.RequestType&&event.ResourceType)return'isCloudFormation';if(event.Records&&(event.Records[0].eventSource==='aws:ses'))return'isSes';if(event.pathParameters&&event.pathParameters.proxy)return'isApiGatewayAwsProxy';if(event.source==='aws.events')return'isScheduledEvent';if(event.awslogs&&event.awslogs.data)return'isCloudWatchLogs';if(event.Records&&(event.Records[0].EventSource==='aws:sns'))return'isSns';if(event.Records&&(event.Records[0].eventSource==='aws:dynamodb'))return'isDynamoDb';if(event.records&&event.records[0].approximateArrivalTimestamp)return'isKinesisFirehose';if(event.records&&event.deliveryStreamArn&&event.deliveryStreamArn.startsWith('arn:aws:kinesis:'))return'isKinesisFirehose';if(event.eventType==='SyncTrigger'&&event.identityId&&event.identityPoolId)return'isCognitoSyncTrigger';if(event.Records&&event.Records[0].eventSource==='aws:kinesis')return'isKinesis';if(event.Records&&event.Records[0].eventSource==='aws:s3')return'isS3';if(event.operation&&event.message)return'isMobileBackend';}Determining Your Event Metadata TodayEvents May Go Beyond Text & JSON
type Event interface {// GetIDreturns the unique ID of the eventGetID() ID// GetTriggerInforetrunsa trigger info provider (stuff from the event listener, protocol specific) GetTriggerInfo() TriggerInfoProvider// GetSchemareturns the Event Body SchemaGetSchema() string// GetContentTypereturns the content type of the body (data blob)GetContentType() string// GetBodyreturns the body (data blob) of the eventGetBody() []byte// GetHeaderreturns the header (context attributes) by name GetHeader(string) string// GetHeadersloads all headers (context attributes) into a map of string GetHeaders() map[string]string// GetFieldreturns the field (within the data/body) by name/path as an interface{}GetField(string) interface{}// GetFieldsloads all data/body fields into a map of string / interface{}GetFields() map[string]interface{}// GetTimestampreturns when the event originatedGetTimestamp() time.Time…}Example Event API (Go)Event API provide a way to pass the event envelope metadata (Schema, type, source, ..) and the event message data/bodyThe API should not expose any event/schema specific information, the event data is accessed via the data/body or the de-serialized version of the data (e.g. using Fields method)Envelopattributesareprovidedasamapofstringstoallowextensibility / optional data