Skip to content

Commit

Permalink
Merge branch 'dev-notify-ckafka' into 'master' (merge request !108)
Browse files Browse the repository at this point in the history
支持kafka回调通知能力
  • Loading branch information
tencentyuncos committed Sep 11, 2024
2 parents d4092f9 + debfcd1 commit 25462d3
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 62 deletions.
138 changes: 76 additions & 62 deletions ci_media.go
Original file line number Diff line number Diff line change
Expand Up @@ -783,33 +783,35 @@ type MediaProcessJobOperation struct {

// CreatePicJobsOptions TODO
type CreatePicJobsOptions struct {
XMLName xml.Name `xml:"Request"`
Tag string `xml:"Tag,omitempty"`
Input *JobInput `xml:"Input,omitempty"`
Operation *PicProcessJobOperation `xml:"Operation,omitempty"`
QueueId string `xml:"QueueId,omitempty"`
CallBack string `xml:"CallBack,omitempty"`
QueueType string `xml:"QueueType,omitempty"`
CallBackFormat string `xml:"CallBackFormat,omitempty"`
CallBackType string `xml:"CallBackType,omitempty"`
CallBackMqConfig *NotifyConfigCallBackMqConfig `xml:"CallBackMqConfig,omitempty"`
XMLName xml.Name `xml:"Request"`
Tag string `xml:"Tag,omitempty"`
Input *JobInput `xml:"Input,omitempty"`
Operation *PicProcessJobOperation `xml:"Operation,omitempty"`
QueueId string `xml:"QueueId,omitempty"`
CallBack string `xml:"CallBack,omitempty"`
QueueType string `xml:"QueueType,omitempty"`
CallBackFormat string `xml:"CallBackFormat,omitempty"`
CallBackType string `xml:"CallBackType,omitempty"`
CallBackMqConfig *NotifyConfigCallBackMqConfig `xml:"CallBackMqConfig,omitempty"`
CallBackKafkaConfig *KafkaConfig `xml:"CallBackKafkaConfig,omitempty"`
}

// CreateAIJobsOptions TODO
type CreateAIJobsOptions CreateMediaJobsOptions

// CreateMediaJobsOptions TODO
type CreateMediaJobsOptions struct {
XMLName xml.Name `xml:"Request"`
Tag string `xml:"Tag,omitempty"`
Input *JobInput `xml:"Input,omitempty"`
Operation *MediaProcessJobOperation `xml:"Operation,omitempty"`
QueueId string `xml:"QueueId,omitempty"`
QueueType string `xml:"QueueType,omitempty"`
CallBackFormat string `xml:"CallBackFormat,omitempty"`
CallBackType string `xml:"CallBackType,omitempty"`
CallBack string `xml:"CallBack,omitempty"`
CallBackMqConfig *NotifyConfigCallBackMqConfig `xml:"CallBackMqConfig,omitempty"`
XMLName xml.Name `xml:"Request"`
Tag string `xml:"Tag,omitempty"`
Input *JobInput `xml:"Input,omitempty"`
Operation *MediaProcessJobOperation `xml:"Operation,omitempty"`
QueueId string `xml:"QueueId,omitempty"`
QueueType string `xml:"QueueType,omitempty"`
CallBackFormat string `xml:"CallBackFormat,omitempty"`
CallBackType string `xml:"CallBackType,omitempty"`
CallBack string `xml:"CallBack,omitempty"`
CallBackMqConfig *NotifyConfigCallBackMqConfig `xml:"CallBackMqConfig,omitempty"`
CallBackKafkaConfig *KafkaConfig `xml:"CallBackKafkaConfig,omitempty"`
}

// NotifyConfigCallBackMqConfig TODO
Expand Down Expand Up @@ -856,16 +858,17 @@ type CreateMediaJobsResult struct {

// CreateMultiMediaJobsOptions TODO
type CreateMultiMediaJobsOptions struct {
XMLName xml.Name `xml:"Request"`
Tag string `xml:"Tag,omitempty"`
Input *JobInput `xml:"Input,omitempty"`
Operation []MediaProcessJobOperation `xml:"Operation,omitempty"`
QueueId string `xml:"QueueId,omitempty"`
QueueType string `xml:"QueueType,omitempty"`
CallBackFormat string `xml:"CallBackFormat,omitempty"`
CallBackType string `xml:"CallBackType,omitempty"`
CallBack string `xml:"CallBack,omitempty"`
CallBackMqConfig *NotifyConfigCallBackMqConfig `xml:"CallBackMqConfig,omitempty"`
XMLName xml.Name `xml:"Request"`
Tag string `xml:"Tag,omitempty"`
Input *JobInput `xml:"Input,omitempty"`
Operation []MediaProcessJobOperation `xml:"Operation,omitempty"`
QueueId string `xml:"QueueId,omitempty"`
QueueType string `xml:"QueueType,omitempty"`
CallBackFormat string `xml:"CallBackFormat,omitempty"`
CallBackType string `xml:"CallBackType,omitempty"`
CallBack string `xml:"CallBack,omitempty"`
CallBackMqConfig *NotifyConfigCallBackMqConfig `xml:"CallBackMqConfig,omitempty"`
CallBackKafkaConfig *KafkaConfig `xml:"CallBackKafkaConfig,omitempty"`
}

// CreateMultiMediaJobsResult TODO
Expand Down Expand Up @@ -1144,14 +1147,21 @@ type MediaProcessQueue struct {

// MediaProcessQueueNotifyConfig TODO
type MediaProcessQueueNotifyConfig struct {
Url string `xml:"Url,omitempty"`
State string `xml:"State,omitempty"`
Type string `xml:"Type,omitempty"`
Event string `xml:"Event,omitempty"`
ResultFormat string `xml:"ResultFormat,omitempty"`
MqMode string `xml:"MqMode,omitempty"`
MqRegion string `xml:"MqRegion,omitempty"`
MqName string `xml:"MqName,omitempty"`
Url string `xml:"Url,omitempty"`
State string `xml:"State,omitempty"`
Type string `xml:"Type,omitempty"`
Event string `xml:"Event,omitempty"`
ResultFormat string `xml:"ResultFormat,omitempty"`
MqMode string `xml:"MqMode,omitempty"`
MqRegion string `xml:"MqRegion,omitempty"`
MqName string `xml:"MqName,omitempty"`
KafkaConfig *KafkaConfig `xml:"KafkaConfig,omitempty"`
}

type KafkaConfig struct {
Region string `xml:"Region,omitempty"`
InstanceId string `xml:"InstanceId,omitempty"`
Topic string `xml:"Topic,omitempty"`
}

// DescribeMediaProcessQueues TODO
Expand Down Expand Up @@ -1804,10 +1814,12 @@ func (s *CIService) DescribeWorkflowExecutions(ctx context.Context, opt *Describ

// NotifyConfig TODO
type NotifyConfig struct {
URL string `xml:"Url,omitempty"`
Event string `xml:"Event,omitempty"`
Type string `xml:"Type,omitempty"`
ResultFormat string `xml:"ResultFormat,omitempty"`
URL string `xml:"Url,omitempty"`
Event string `xml:"Event,omitempty"`
Type string `xml:"Type,omitempty"`
ResultFormat string `xml:"ResultFormat,omitempty"`
State string `xml:"State,omitempty"`
KafkaConfig *KafkaConfig `xml:"KafkaConfig,omitempty" json:"KafkaConfig,omitempty"`
}

// ExtFilter TODO
Expand Down Expand Up @@ -2127,16 +2139,17 @@ type ASRJobOperation struct {

// CreateASRJobsOptions TODO
type CreateASRJobsOptions struct {
XMLName xml.Name `xml:"Request"`
Tag string `xml:"Tag,omitempty"`
Input *JobInput `xml:"Input,omitempty"`
Operation *ASRJobOperation `xml:"Operation,omitempty"`
QueueId string `xml:"QueueId,omitempty"`
CallBack string `xml:"CallBack,omitempty"`
QueueType string `xml:"QueueType,omitempty"`
CallBackFormat string `xml:"CallBackFormat,omitempty"`
CallBackType string `xml:"CallBackType,omitempty"`
CallBackMqConfig *NotifyConfigCallBackMqConfig `xml:"CallBackMqConfig,omitempty"`
XMLName xml.Name `xml:"Request"`
Tag string `xml:"Tag,omitempty"`
Input *JobInput `xml:"Input,omitempty"`
Operation *ASRJobOperation `xml:"Operation,omitempty"`
QueueId string `xml:"QueueId,omitempty"`
CallBack string `xml:"CallBack,omitempty"`
QueueType string `xml:"QueueType,omitempty"`
CallBackFormat string `xml:"CallBackFormat,omitempty"`
CallBackType string `xml:"CallBackType,omitempty"`
CallBackMqConfig *NotifyConfigCallBackMqConfig `xml:"CallBackMqConfig,omitempty"`
CallBackKafkaConfig *KafkaConfig `xml:"CallBackKafkaConfig,omitempty"`
}

// ASRJobDetail TODO
Expand Down Expand Up @@ -4117,16 +4130,17 @@ type GeneratePlayListJobOperation struct {
}

type CreateGeneratePlayListJobOptions struct {
XMLName xml.Name `xml:"Request"`
Tag string `xml:"Tag,omitempty"`
Input *JobInput `xml:"Input,omitempty"`
Operation *GeneratePlayListJobOperation `xml:"Operation,omitempty"`
QueueId string `xml:"QueueId,omitempty"`
QueueType string `xml:"QueueType,omitempty"`
CallBackFormat string `xml:"CallBackFormat,omitempty"`
CallBackType string `xml:"CallBackType,omitempty"`
CallBack string `xml:"CallBack,omitempty"`
CallBackMqConfig *NotifyConfigCallBackMqConfig `xml:"CallBackMqConfig,omitempty"`
XMLName xml.Name `xml:"Request"`
Tag string `xml:"Tag,omitempty"`
Input *JobInput `xml:"Input,omitempty"`
Operation *GeneratePlayListJobOperation `xml:"Operation,omitempty"`
QueueId string `xml:"QueueId,omitempty"`
QueueType string `xml:"QueueType,omitempty"`
CallBackFormat string `xml:"CallBackFormat,omitempty"`
CallBackType string `xml:"CallBackType,omitempty"`
CallBack string `xml:"CallBack,omitempty"`
CallBackMqConfig *NotifyConfigCallBackMqConfig `xml:"CallBackMqConfig,omitempty"`
CallBackKafkaConfig *KafkaConfig `xml:"CallBackKafkaConfig,omitempty"`
}

func (s *CIService) CreateGeneratePlayListJob(ctx context.Context, opt *CreateGeneratePlayListJobOptions) (*CreateJobsResult, *Response, error) {
Expand Down
20 changes: 20 additions & 0 deletions example/CI/workflow_and_job/ci_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,26 @@ func log_status(err error) {
}
}

func getClient() *cos.Client {
u, _ := url.Parse("https://test-1234567890.cos.ap-chongqing.myqcloud.com")
cu, _ := url.Parse("https://test-1234567890.ci.ap-chongqing.myqcloud.com")
b := &cos.BaseURL{BucketURL: u, CIURL: cu}
c := cos.NewClient(b, &http.Client{
Transport: &cos.AuthorizationTransport{
SecretID: os.Getenv("COS_SECRETID"),
SecretKey: os.Getenv("COS_SECRETKEY"),
Transport: &debug.DebugRequestTransport{
RequestHeader: true,
// Notice when put a large file and set need the request body, might happend out of memory error.
RequestBody: true,
ResponseHeader: true,
ResponseBody: true,
},
},
})
return c
}

// GetMediaQueue 获取媒体处理队列
func GetMediaQueue() {
u, _ := url.Parse("https://test-1234567890.cos.ap-chongqing.myqcloud.com")
Expand Down

0 comments on commit 25462d3

Please sign in to comment.