Coder Social home page Coder Social logo

event-center-sdk-go-test's Introduction

#使用说明

1 参数说明

1.1 client参数说明

参数名 类型 是否必填 说明
eventSink string 事件中心的url

1.2 event参数说明

参数名 类型 是否必填 说明
subject string 事件主题:operate、alter、log等
source string 事件来源:inspurcloud.产品代码(组件编码
type string 事件类型:inspurcloud.产品代码.资源.操作
resource string 资源类型:资源的类型,由各产品自己定义
accountid string 账户
action string 动作类型:在subject为operate时可以设为操作的类型。可选为create,list,modify,delete。
region string 区域
body interface{} 报文体:事件数据的报文体

2 示例

package main

import (
	"context"
	"fmt"

	icclent "cloud.inspur.com/event-center-sdk-go/client"
	icevent "cloud.inspur.com/event-center-sdk-go/event"
)

func main()  {
	c, _ := icclent.Init("http://localhost:8081")

	event := icevent.NewEvent()
	event.SetSubject("subject1")
	event.SetType("type")
	event.SetSource("source1")
	event.SetResource("rsource")
	event.SetAccountid("accoun")
	event.SetAction("list")
	event.SetRegion("rego")
	var data = map[string]string{"name":"asdf", "id":"47178080808"}
	err := event.SetBody(data)
	err = c.Send(context.Background(), event)
	if err != nil {
		fmt.Println(err)
	}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.