123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- package funcgraph
- import (
- "assetcenter/conf"
- "fmt"
- "strings"
- "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
- functiongraph "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/functiongraph/v2"
- "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/functiongraph/v2/model"
- region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/functiongraph/v2/region"
- )
- const (
- ak = "RA1D7CFVCVKUFX1FHHPB"
- sk = "cDrR2NgAF2KaA4MRkcK19r93P3P6hLKOPhHvPu9p"
- )
- func createFuncGraphClient() *functiongraph.FunctionGraphClient {
- auth := basic.NewCredentialsBuilder().
- WithAk(ak).
- WithSk(sk).
- Build()
- return functiongraph.NewFunctionGraphClient(
- functiongraph.FunctionGraphClientBuilder().
- WithRegion(region.ValueOf("cn-east-3")).
- WithCredential(auth).
- Build())
- }
- func OsgConvRequest(meshUrl string, assetId string, dbId string, table string, natsUrl string) error {
- OsgConvStreamTopic := conf.AppConfig.Nats.OsgConvStreamTopic
- streamTopics := strings.Split(OsgConvStreamTopic, "#")
- client := createFuncGraphClient()
- request := &model.AsyncInvokeFunctionRequest{Body: map[string]interface{}{
- "meshUrl": meshUrl,
- "assetId": assetId,
- "dbId": dbId,
- "table": table,
- "notifyNatsUrl": natsUrl,
- "notifyStream": streamTopics[0],
- "notifySubject": streamTopics[1],
- }}
- fmt.Println(request)
- // request.FunctionUrn = "urn:fss:cn-east-3:0956c65fd600f29f2ff6c00dbb3d1e2e:function:default:osgconv:v1"
- // request.FunctionUrn = "urn:fss:cn-east-3:0956c65fd600f29f2ff6c00dbb3d1e2e:function:default:osgconv:v2"
- request.FunctionUrn = "urn:fss:cn-east-3:0956c65fd600f29f2ff6c00dbb3d1e2e:function:default:osgconv:latest"
- response, err := client.AsyncInvokeFunction(request)
- if err == nil {
- fmt.Printf("%+v\n", response)
- return nil
- }
- fmt.Println(err)
- return err
- }
|