shadow.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package funcgraph
  2. import (
  3. "assetcenter/conf"
  4. "fmt"
  5. "strings"
  6. "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/functiongraph/v2/model"
  7. )
  8. func CreateShadow(meshUrl string, assetId string, dbId string, table string, scale, width int32, natsUrl string) error {
  9. client := createFuncGraphClient()
  10. OsgConvStreamTopic := conf.AppConfig.Nats.OsgShadowStreamTopic
  11. streamTopics := strings.Split(OsgConvStreamTopic, "#")
  12. request := &model.AsyncInvokeFunctionRequest{Body: map[string]interface{}{
  13. "meshUrl": meshUrl,
  14. "assetId": assetId,
  15. "dbId": dbId,
  16. "table": table,
  17. "scalex10": scale,
  18. "width": width,
  19. "notifyNatsUrl": natsUrl,
  20. "notifyStream": streamTopics[0],
  21. "notifySubject": streamTopics[1],
  22. }}
  23. request.FunctionUrn = "urn:fss:cn-east-3:0956c65fd600f29f2ff6c00dbb3d1e2e:function:default:shadowconv:latest"
  24. response, err := client.AsyncInvokeFunction(request)
  25. if err == nil {
  26. fmt.Printf("%+v\n notifyNatsUrl:%s notifyStream: %s notifySubject:%s", response, natsUrl, streamTopics[0], streamTopics[1])
  27. return nil
  28. }
  29. fmt.Println("CreateShadow request failed=>", err.Error())
  30. return err
  31. }