events

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

README

概述

此程序包为 FC 函数提供了不同阿里云事件源的输入类型。

案例

http 事件格式]

OSS 事件格式

SLS 事件格式

MNS Topic 事件格式

SLS Queue 事件格式

Kafka Eventbridge 事件格式

RocketMQ 事件格式

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

type Bucket struct {
	Arn           *string `json:"arn"`
	Name          *string `json:"name"`
	OwnerIdentity *string `json:"ownerIdentity"`
	VirtualBucket *string `json:"virtualBucket"`
}

type Data added in v0.2.1

type Data struct {
	RequestID   *string `json:"requestId"`
	MessageID   *string `json:"messageId"`
	MessageBody *string `json:"messageBody"`
}

type HTTPTriggerEvent added in v0.2.8

type HTTPTriggerEvent struct {
	Version         *string            `json:"version"`         // HTTP 触发器请求事件版本
	RawPath         *string            `json:"rawPath"`         // 未经解析的路径
	Body            *string            `json:"body"`            // 请求体
	IsBase64Encoded *bool              `json:"isBase64Encoded"` // 请求体是否以 Base64 编码
	Headers         *map[string]string `json:"headers"`         // HTTP 请求头
	QueryParameters *map[string]string `json:"queryParameters"` // 查询 Param
	// RequestContext 包含请求的上下文信息
	TriggerContext HTTPTriggerRequestContext `json:"requestContext"`
}

HTTPTriggerEvent 事件输入

type HTTPTriggerRequestContext added in v0.2.8

type HTTPTriggerRequestContext struct {
	AccountId    *string `json:"accountId"`    // 账户 ID
	DomainName   *string `json:"domainName"`   // 域名
	DomainPrefix *string `json:"domainPrefix"` // 域名前缀
	// Http 结构体包含 HTTP 请求的详细信息
	Http struct {
		Method    *string `json:"method"`    // 请求方法
		Path      *string `json:"path"`      // 请求路径
		Protocol  *string `json:"protocol"`  // 请求协议
		SourceIp  *string `json:"sourceIp"`  // 请求来源 IP
		UserAgent *string `json:"userAgent"` // 客户端标识,如: Mozilla/5.0
	} `json:"http"`
	RequestId *string `json:"requestId"` // 请求 ID
	Time      *string `json:"time"`      // 请求时间
	TimeEpoch *string `json:"timeEpoch"` // 时间戳(epoch 时间)
}

HTTPTriggerRequestContext 用于存储上下文信息

type HTTPTriggerResponse added in v0.2.8

type HTTPTriggerResponse struct {
	StatusCode      int               `json:"statusCode"`
	Headers         map[string]string `json:"headers"`
	IsBase64Encoded bool              `json:"isBase64Encoded"`
	Body            string            `json:"body"`
}

HTTPTriggerResponse 定义了 HTTP 响应的结构体 主要包括状态码、头部信息、是否以 Base64 编码、响应体四个部分

type KafkaData added in v0.2.2

type KafkaData struct {
	Topic     *string          `json:"topic"`
	Partition *int             `json:"partition"`
	Offset    *int             `json:"offset"`
	Timestamp *int             `json:"timestamp"`
	Headers   *KafkaDataHeader `json:"headers"`
	Value     *string          `json:"value"`
}

type KafkaDataHeader added in v0.2.2

type KafkaDataHeader struct {
	Headers    []*string `json:"headers"`
	IsReadOnly *bool     `json:"isReadOnly"`
}

type KafkaEventBridgeEvent added in v0.2.2

type KafkaEventBridgeEvent struct {
	Data            *KafkaData `json:"data"`
	Id              *string    `json:"id"`
	Source          *string    `json:"source"`
	SpecVersion     *string    `json:"specversion"`
	Type            *string    `json:"type"`
	DataContentType *string    `json:"datacontenttype"`
	Time            *string    `json:"time"`
	Subject         *string    `json:"subject"`
	AliyunAccountId *string    `json:"aliyunaccountid"`
}

type MnsQueueEvent added in v0.2.1

type MnsQueueEvent struct {
	ID                      *string   `json:"id"`
	Source                  *string   `json:"source"`
	Specversion             *string   `json:"specversion"`
	Type                    *string   `json:"type"`
	Datacontenttype         *string   `json:"datacontenttype"`
	Subject                 *string   `json:"subject"`
	Time                    time.Time `json:"time"`
	Aliyunaccountid         *string   `json:"aliyunaccountid"`
	Aliyunpublishtime       time.Time `json:"aliyunpublishtime"`
	Aliyunoriginalaccountid *string   `json:"aliyunoriginalaccountid"`
	Aliyuneventbusname      *string   `json:"aliyuneventbusname"`
	Aliyunregionid          *string   `json:"aliyunregionid"`
	Aliyunpublishaddr       *string   `json:"aliyunpublishaddr"`
	Data                    *Data     `json:"data"`
}

type MnsTopicEvent added in v0.2.1

type MnsTopicEvent struct {
	TopicOwner       *string   `json:"TopicOwner"`
	Message          *string   `json:"Message"`
	Subscriber       *string   `json:"Subscriber"`
	PublishTime      time.Time `json:"PublishTime"`
	SubscriptionName *string   `json:"SubscriptionName"`
	MessageMD5       *string   `json:"MessageMD5"`
	TopicName        *string   `json:"TopicName"`
	MessageID        *string   `json:"MessageId"`
}

type Object

type Object struct {
	DeltaSize  *int        `json:"deltaSize"`
	ETag       *string     `json:"eTag"`
	Key        *string     `json:"key"`
	ObjectMeta *ObjectMeta `json:"objectMeta"`
	Size       *int        `json:"size"`
}

type ObjectMeta

type ObjectMeta struct {
	MimeType *string `json:"mimeType"`
}

type Oss

type Oss struct {
	Bucket           *Bucket `json:"bucket"`
	Object           *Object `json:"object"`
	OssSchemaVersion *string `json:"ossSchemaVersion"`
	RuleID           *string `json:"ruleId"`
}

type OssEvent

type OssEvent struct {
	Events []*OssEventRecord `json:"events"`
}

type OssEventRecord

type OssEventRecord struct {
	EventName         *string            `json:"eventName"`
	EventSource       *string            `json:"eventSource"`
	EventTime         *time.Time         `json:"eventTime"`
	EventVersion      *string            `json:"eventVersion"`
	Oss               *Oss               `json:"oss"`
	Region            *string            `json:"region"`
	RequestParameters *RequestParameters `json:"requestParameters"`
	ResponseElements  *ResponseElements  `json:"responseElements"`
	UserIdentity      *UserIdentity      `json:"userIdentity"`
}

type Parameter

type Parameter interface{}

type RequestParameters

type RequestParameters struct {
	SourceIPAddress *string `json:"sourceIPAddress"`
}

type ResponseElements

type ResponseElements struct {
	RequestID *string `json:"requestId"`
}

type RocketMQData added in v0.2.8

type RocketMQData struct {
	Topic            string            `json:"topic"`
	SystemProperties map[string]string `json:"systemProperties"`
	UserProperties   map[string]string `json:"userProperties"`
	Body             string            `json:"body"`
}

type RocketMQEvent added in v0.2.8

type RocketMQEvent struct {
	ID                      *string       `json:"id"`
	Source                  *string       `json:"source"`
	SpecVersion             *string       `json:"specversion"`
	Type                    *string       `json:"type"`
	DataContentType         *string       `json:"datacontenttype"`
	Subject                 *string       `json:"subject"`
	Time                    *time.Time    `json:"time"`
	AliyunAccountId         *string       `json:"aliyunaccountid"`
	AliyunPublishTime       *time.Time    `json:"aliyunpublishtime"`
	AliyunOriginalAccountId *string       `json:"aliyunoriginalaccountid"`
	AliyunEventBusName      *string       `json:"aliyuneventbusname"`
	AliyunRegionId          *string       `json:"aliyunregionid"`
	AliyunPublishAddr       *string       `json:"aliyunpublishaddr"`
	Data                    *RocketMQData `json:"data"`
}

type SlsEvent

type SlsEvent struct {
	CursorTime *int       `json:"cursorTime"`
	JobName    *string    `json:"jobName"`
	Parameter  *Parameter `json:"parameter"`
	Source     *Source    `json:"source"`
	TaskID     *string    `json:"taskId"`
}

type Source

type Source struct {
	BeginCursor  *string `json:"beginCursor"`
	EndCursor    *string `json:"endCursor"`
	Endpoint     *string `json:"endpoint"`
	LogstoreName *string `json:"logstoreName"`
	ProjectName  *string `json:"projectName"`
	ShardID      *int    `json:"shardId"`
}

type TimerEvent added in v0.2.2

type TimerEvent struct {
	TriggerTime *string `json:"triggerTime"`
	TriggerName *string `json:"triggerName"`
	Payload     *string `json:"payload"`
}

type UserIdentity

type UserIdentity struct {
	PrincipalID *string `json:"principalId"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL