api_client_go

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: MIT Imports: 54 Imported by: 0

README

api-client-go

api-client-go 是一个面向 IOT 平台的 Go 客户端库,用于统一访问平台内多个 gRPC 服务,并封装认证、服务发现、配置加载与本地调试能力。

当前模块名:

module github.com/zhgqiang/api-client-go

功能概览

  • 统一聚合多个业务客户端到一个 Client
  • 基于 AK/SK 自动获取并刷新访问令牌
  • 支持通过 etcd + Kratos registry 发现服务
  • 支持从配置中心加载配置并合并到本地参数
  • 支持 LiteMode 跳过注册中心能力
  • 支持本地 local_grpc 方式进行调试或测试
  • 提供常用业务访问入口,例如:
    • AuthClient
    • SpmClient
    • CoreClient
    • FlowClient
    • WarningClient
    • DriverClient
    • DataServiceClient
    • FlowEngineClient
    • ReportClient
    • LiveClient
    • AlgorithmClient
    • DataRelayClient
    • JsServerClient
    • SyncClient
    • SyslogClient
    • ComputeRecordClient
    • AIClient
    • RecordClient

主入口定义见 client.go:42

安装

go get github.com/zhgqiang/api-client-go

依赖要求

通常需要以下基础设施之一:

1. 标准 gRPC / 注册中心模式

适用于实际接入平台服务:

  • etcd
  • Kratos registry
  • 有效的 AK/SK
2. 本地模式

适用于测试或嵌入式本地调用:

  • 本地构造 local_grpc.Server
  • 使用 NewLocalClient(...)

快速开始

创建 etcd 客户端
package main

import (
    "log"
    "time"

    api_client_go "github.com/zhgqiang/api-client-go"
    "github.com/zhgqiang/api-client-go/config"
    clientv3 "go.etcd.io/etcd/client/v3"
    "google.golang.org/grpc"
)

func main() {
    etcdCli, err := clientv3.New(clientv3.Config{
        Endpoints:   []string{"127.0.0.1:2379"},
        DialTimeout: 60 * time.Second,
        DialOptions: []grpc.DialOption{grpc.WithBlock()},
    })
    if err != nil {
        log.Fatal(err)
    }
    defer etcdCli.Close()

    cli, clean, err := api_client_go.NewClient(etcdCli, config.Config{
        LiteMode:   false,
        EtcdConfig: "/config/dev.json",
        Metadata: map[string]string{
            "env": "aliyun",
        },
        Type:      config.Tenant,
        AK:        "your-ak",
        SK:        "your-sk",
        Timeout:   60,
        KeepAlive: true,
    })
    if err != nil {
        log.Fatal(err)
    }
    defer clean()

    _ = cli
}

NewClient(...) 定义见 client.go:67

配置说明

配置结构定义见 config/config.go:12

config.Config{
    LiteMode:   false,
    Gateway:    "",
    GatewayGrpc:"127.0.0.1:9224",
    EtcdConfig: "/config/dev.json",
    Metadata: map[string]string{
        "env": "aliyun",
    },
    Services: map[string]config.Service{
        // "core": {Metadata: map[string]string{"env": "local"}},
    },
    Type:      config.Tenant, // 或 config.Project
    ProjectId: "",
    AK:        "your-ak",
    SK:        "your-sk",
    Timeout:   60,
}
关键字段
  • LiteMode:为 true 时不走配置中心 / 注册中心完整逻辑
  • EtcdConfig:配置中心路径,如 /config/dev.json
  • Metadata["env"]:用于服务发现时筛选环境
  • Services:可为某个具体服务单独指定 metadata 或直连地址
  • Type:认证类型,支持:
    • config.Tenant
    • config.Project
  • ProjectId:当 Type == config.Project 时使用
  • AK / SK:平台认证凭据
  • Timeout:请求超时时间

认证机制

认证客户端定义见 auth/auth_client.go:24

库会通过 AK/SK 自动获取 token,并在过期前按 ExpirePrecision 提前刷新。

你也可以直接获取当前 token:

token, err := cli.GetToken()

实现见 auth.go:3

常见用法

查询项目
package main

import "context"

func example(cli *api_client_go.Client) error {
    var result []map[string]interface{}
    return cli.QueryProject(context.Background(), map[string]interface{}{}, &result)
}

相关测试示例见 test/client_test.go:182

查询表结构
package main

import "context"

func example(cli *api_client_go.Client, projectID string) error {
    var result []map[string]interface{}
    return cli.QueryTableSchema(context.Background(), projectID, map[string]interface{}{}, &result)
}

相关示例见 client_test.go:126test/client_test.go:130

运行流程
package main

import "context"

func example(cli *api_client_go.Client, projectID string, flowConfig string, element []byte, vars map[string]interface{}) error {
    _, err := cli.Run(context.Background(), projectID, flowConfig, element, vars)
    return err
}

相关示例见 client_test.go:58

本地调试模式

如果你已经在进程内注册了若干 gRPC service,可使用本地模式:

ss := local_grpc.NewServer()

cli, clean, err := api_client_go.NewLocalClient(cfg, ss)
if err != nil {
    return err
}
defer clean()
  • 本地 server 定义见 local_grpc/server.go:40
  • 本地客户端入口见 client.go:71

这种方式适合:

  • 单元测试
  • 本地联调
  • 无需真实网络连接的服务调用模拟

服务可用性检查

聚合客户端还提供了服务缓存与服务存在性检查能力:

ok, err := cli.Service.IsExist(ctx, "js-server")

实现见 service.go:29

项目结构

主要目录说明:

  • config/:配置结构定义
  • auth/:认证与凭据处理
  • local_grpc/:本地 gRPC 调试实现
  • apicontext/:请求上下文辅助封装
  • errors/:平台响应错误解析
  • ai/core/flow/driver/report/ 等:各服务 proto 与客户端封装
  • test/:集成测试与使用示例

注意事项

  • 当前仓库包含大量由 proto 生成的 *.pb.go*_grpc.pb.go 文件
  • 部分测试依赖真实环境、真实 etcd、真实服务地址和有效凭据,不能直接在纯本地环境运行
  • test/client_test.go 中存在演示性质的环境配置,实际使用时请替换为你自己的地址和凭据

参考代码位置

  • 聚合客户端:client.go:42
  • 标准客户端初始化:client.go:67
  • 本地客户端初始化:client.go:71
  • 配置结构:config/config.go:12
  • 认证逻辑:auth/auth_client.go:24
  • 本地 gRPC server:local_grpc/server.go:40
  • 服务检查:service.go:13

License

如果你需要开源发布,建议补充明确的 License 文件;当前仓库根目录尚未看到独立 license 说明。

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Config config.Config

	RegistryClient      *KratosRegistryClient
	AuthClient          *auth.Client
	SpmClient           *spm.Client
	CoreClient          *core.Client
	FlowClient          *flow.Client
	WarningClient       *warning.Client
	DriverClient        *driver.Client
	DataServiceClient   *dataservice.Client
	FlowEngineClient    *engine.Client
	ReportClient        *report.Client
	LiveClient          *live.Client
	AlgorithmClient     *algorithm.Client
	DataRelayClient     *datarelay.Client
	JsServerClient      *jsserver.Client
	SyncClient          *sync.Client
	SyslogClient        *syslog.Client
	ComputeRecordClient *computerecord.Client
	AIClient            *ai.Client
	RecordClient        *record.Client
	Service             *Service
}

func NewClient

func NewClient(cli *clientv3.Client, cfg config.Config) (*Client, func(), error)

func NewLocalClient

func NewLocalClient(cfg config.Config, ss *local_grpc.Server) (*Client, func(), error)

func (*Client) AdminRoleCheck

func (c *Client) AdminRoleCheck(ctx context.Context, projectId, token string, result interface{}) error

func (*Client) AlgorithmRunById

func (c *Client) AlgorithmRunById(ctx context.Context, projectId, id string, data interface{}) ([]byte, error)

AlgorithmRunById 算法执行

func (*Client) BatchCommand

func (c *Client) BatchCommand(ctx context.Context, projectId string, data interface{}, result interface{}) error

BatchCommand 批量执行指令

func (*Client) BatchCreateFlow

func (c *Client) BatchCreateFlow(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) BatchCreateFlowTask

func (c *Client) BatchCreateFlowTask(ctx context.Context, projectId string, createData, result interface{}) error

BatchCreateFlowTask FlowTask

func (*Client) BatchCreateReport

func (c *Client) BatchCreateReport(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) BatchCreateReportCopy

func (c *Client) BatchCreateReportCopy(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) BatchCreateRule

func (c *Client) BatchCreateRule(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) BatchCreateWarn

func (c *Client) BatchCreateWarn(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) CallAIModel

func (c *Client) CallAIModel(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) CallBigModel

func (c *Client) CallBigModel(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) ChangeCommand

func (c *Client) ChangeCommand(ctx context.Context, projectId, id string, data, result interface{}) error

ChangeCommand 执行指令

func (*Client) CreateApiPermission

func (c *Client) CreateApiPermission(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) CreateDashboard

func (c *Client) CreateDashboard(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) CreateDataGroups

func (c *Client) CreateDataGroups(ctx context.Context, projectId string, createData, result interface{}) (int64, error)

func (*Client) CreateDataInterfaces

func (c *Client) CreateDataInterfaces(ctx context.Context, projectId string, createData, result interface{}) (int64, error)

func (*Client) CreateDataRelayService

func (c *Client) CreateDataRelayService(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) CreateDatasetView

func (c *Client) CreateDatasetView(ctx context.Context, projectId string, datasetView, result interface{}) error

func (*Client) CreateDatasetWhole

func (c *Client) CreateDatasetWhole(ctx context.Context, projectId string, datasetWhole, result interface{}) error

func (*Client) CreateDriverEventCron

func (c *Client) CreateDriverEventCron(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) CreateDriverInstance

func (c *Client) CreateDriverInstance(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) CreateDriverInstructCron

func (c *Client) CreateDriverInstructCron(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) CreateFlowJobCron

func (c *Client) CreateFlowJobCron(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) CreateFlowLogCron

func (c *Client) CreateFlowLogCron(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) CreateFlowTask

func (c *Client) CreateFlowTask(ctx context.Context, projectId string, createData, result interface{}) error

CreateFlowTask FlowTask

func (*Client) CreateFlowTriggerRecord

func (c *Client) CreateFlowTriggerRecord(ctx context.Context, projectId string, createData, result interface{}) error

CreateFlowTriggerRecord FlowTriggerRecord

func (*Client) CreateLocalAlgorithm

func (c *Client) CreateLocalAlgorithm(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) CreateLog

func (c *Client) CreateLog(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) CreateManyDriverEventCron

func (c *Client) CreateManyDriverEventCron(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) CreateManyDriverInstructCron

func (c *Client) CreateManyDriverInstructCron(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) CreateManyFlowJobCron

func (c *Client) CreateManyFlowJobCron(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) CreateManyFlowLogCron

func (c *Client) CreateManyFlowLogCron(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) CreateManyLocalAlgorithm

func (c *Client) CreateManyLocalAlgorithm(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) CreateManyTableData

func (c *Client) CreateManyTableData(ctx context.Context, projectId, tableName string, closeRequire bool, createData, result interface{}) error

func (*Client) CreateManyTableDataByDB

func (c *Client) CreateManyTableDataByDB(ctx context.Context, projectId, tableName string, createData, result interface{}) error

func (*Client) CreateManyUserBackup

func (c *Client) CreateManyUserBackup(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) CreateMediaLibraryDirSetting

func (c *Client) CreateMediaLibraryDirSetting(ctx context.Context, projectId string, createData, result interface{}) error

CreateMediaLibraryDirSetting 媒体库文件夹设置

func (*Client) CreateMessage

func (c *Client) CreateMessage(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) CreateProject

func (c *Client) CreateProject(ctx context.Context, createData, result interface{}) error

func (*Client) CreateReport

func (c *Client) CreateReport(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) CreateSync

func (c *Client) CreateSync(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) CreateSystemVariable

func (c *Client) CreateSystemVariable(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) CreateTableData

func (c *Client) CreateTableData(ctx context.Context, projectId, tableName string, closeRequire bool, createData, result interface{}) error

func (*Client) CreateTableDataByDB

func (c *Client) CreateTableDataByDB(ctx context.Context, projectId, tableName string, createData, result interface{}) error

func (*Client) CreateTableRecord

func (c *Client) CreateTableRecord(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) CreateTableSchema

func (c *Client) CreateTableSchema(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) CreateTaskManager

func (c *Client) CreateTaskManager(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) CreateUser

func (c *Client) CreateUser(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) CreateWarn

func (c *Client) CreateWarn(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) DataInterfaceProxy

func (c *Client) DataInterfaceProxy(ctx context.Context, projectId, key string, data map[string]interface{}) (*ProxyResult, error)

func (*Client) DatasetPreview

func (c *Client) DatasetPreview(ctx context.Context, projectId, mode, datesetId string, data any, result interface{}) ([]byte, error)

data是数据集配置

func (*Client) DatasetViewPreview

func (c *Client) DatasetViewPreview(ctx context.Context, projectId, mode, datesetId, viewId string, data *QueryParam, result interface{}) ([]byte, error)

func (*Client) DeleteAllDatasetViews

func (c *Client) DeleteAllDatasetViews(ctx context.Context, projectId string) (int64, error)

删除全部数据集视图(仅备份还原使用),有特殊认证

func (*Client) DeleteAllDatasets

func (c *Client) DeleteAllDatasets(ctx context.Context, projectId string) (int64, error)

删除全部数据集(仅备份还原使用),有特殊认证

func (*Client) DeleteBackup

func (c *Client) DeleteBackup(ctx context.Context, projectId, id string, result interface{}) error

func (*Client) DeleteDataGroup

func (c *Client) DeleteDataGroup(ctx context.Context, projectId, id string) error

func (*Client) DeleteDataInterface

func (c *Client) DeleteDataInterface(ctx context.Context, projectId, id string) error

func (*Client) DeleteDataRelayService

func (c *Client) DeleteDataRelayService(ctx context.Context, projectId, id string, result interface{}) error

func (*Client) DeleteDriverEventCron

func (c *Client) DeleteDriverEventCron(ctx context.Context, projectId, id string) error

func (*Client) DeleteDriverInstance

func (c *Client) DeleteDriverInstance(ctx context.Context, projectId, id string, result interface{}) error

func (*Client) DeleteDriverInstructCron

func (c *Client) DeleteDriverInstructCron(ctx context.Context, projectId, id string) error

func (*Client) DeleteFlow

func (c *Client) DeleteFlow(ctx context.Context, projectId, id string, result interface{}) error

func (*Client) DeleteFlowJobCron

func (c *Client) DeleteFlowJobCron(ctx context.Context, projectId, id string) error

func (*Client) DeleteFlowLogCron

func (c *Client) DeleteFlowLogCron(ctx context.Context, projectId, id string) error

func (*Client) DeleteFlowTask

func (c *Client) DeleteFlowTask(ctx context.Context, projectId, id string, result interface{}) error

func (*Client) DeleteLocalAlgorithm

func (c *Client) DeleteLocalAlgorithm(ctx context.Context, projectId, id string) error

func (*Client) DeleteManyDataGroups

func (c *Client) DeleteManyDataGroups(ctx context.Context, projectId string, filter interface{}) (int64, error)

func (*Client) DeleteManyDataInterfaces

func (c *Client) DeleteManyDataInterfaces(ctx context.Context, projectId string, filter interface{}) (int64, error)

func (*Client) DeleteManyDriverEventCron

func (c *Client) DeleteManyDriverEventCron(ctx context.Context, projectId string, query interface{}) (int64, error)

func (*Client) DeleteManyDriverInstructCron

func (c *Client) DeleteManyDriverInstructCron(ctx context.Context, projectId string, query interface{}) (int64, error)

func (*Client) DeleteManyFlowJobCron

func (c *Client) DeleteManyFlowJobCron(ctx context.Context, projectId string, query interface{}) (int64, error)

func (*Client) DeleteManyFlowLogCron

func (c *Client) DeleteManyFlowLogCron(ctx context.Context, projectId string, query interface{}) (int64, error)

func (*Client) DeleteManyLocalAlgorithm

func (c *Client) DeleteManyLocalAlgorithm(ctx context.Context, projectId string, query interface{}) (int64, error)

func (*Client) DeleteManyTableData

func (c *Client) DeleteManyTableData(ctx context.Context, projectId, tableName string, query, result interface{}) error

func (*Client) DeleteManyTableDataByDB

func (c *Client) DeleteManyTableDataByDB(ctx context.Context, projectId, tableName string, query, result interface{}) error

func (*Client) DeleteManyUserBackup

func (c *Client) DeleteManyUserBackup(ctx context.Context, projectId string, query, result interface{}) error

func (*Client) DeleteMediaLibraryDirSetting

func (c *Client) DeleteMediaLibraryDirSetting(ctx context.Context, projectId, id string, result interface{}) error

func (*Client) DeleteProject

func (c *Client) DeleteProject(ctx context.Context, id string, result interface{}) error

func (*Client) DeleteReport

func (c *Client) DeleteReport(ctx context.Context, projectId, id string, result interface{}) error

func (*Client) DeleteReportCopy

func (c *Client) DeleteReportCopy(ctx context.Context, projectId, id string, result interface{}) error

func (*Client) DeleteRule

func (c *Client) DeleteRule(ctx context.Context, projectId, id string, result interface{}) error

func (*Client) DeleteSync

func (c *Client) DeleteSync(ctx context.Context, projectId, id string, result interface{}) error

func (*Client) DeleteSystemVariable

func (c *Client) DeleteSystemVariable(ctx context.Context, projectId, id string, result interface{}) error

func (*Client) DeleteTableData

func (c *Client) DeleteTableData(ctx context.Context, projectId, tableName, id string, result interface{}) error

func (*Client) DeleteTableDataByDB

func (c *Client) DeleteTableDataByDB(ctx context.Context, projectId, tableName, id string, result interface{}) error

func (*Client) DeleteTableRecord

func (c *Client) DeleteTableRecord(ctx context.Context, projectId, id string, result interface{}) error

func (*Client) DeleteTableSchema

func (c *Client) DeleteTableSchema(ctx context.Context, projectId, id string, result interface{}) error

func (*Client) DeleteTaskManager

func (c *Client) DeleteTaskManager(ctx context.Context, projectId, id string, result interface{}) error

func (*Client) DeleteUser

func (c *Client) DeleteUser(ctx context.Context, projectId, id string, result interface{}) error

func (*Client) DownloadBackup

func (c *Client) DownloadBackup(ctx context.Context, projectId, id, password string, w io.Writer) error

func (*Client) DownloadFile

func (c *Client) DownloadFile(ctx context.Context, projectId string, path string, saveFile string) error

DownloadFile 下载媒体库文件到本地

projectId: 项目ID path: 媒体库文件路径. /core/fileServer/mediaLibrary/projectId/{filePath} 或 {filePath} saveFile: 保存到本地文件的路径

func (*Client) DownloadFileData

func (c *Client) DownloadFileData(ctx context.Context, projectId string, path string) ([]byte, error)

DownloadFileData 下载媒体库文件到本地

projectId: 项目ID path: 媒体库文件路径. /core/fileServer/mediaLibrary/projectId/{filePath} 或 {filePath}

返回值: 文件的字节数组, 错误

func (*Client) DriverBatchWriteTag

func (c *Client) DriverBatchWriteTag(ctx context.Context, projectId string, data *DriverBatchWriteTag, result interface{}) error

DriverBatchWriteTag 执行写数据点

func (*Client) DriverWriteTag

func (c *Client) DriverWriteTag(ctx context.Context, projectId string, data *DriverWriteTag, result interface{}) error

DriverWriteTag 执行写数据点

func (*Client) ExportBackup

func (c *Client) ExportBackup(ctx context.Context, projectId string, query interface{}) (string, error)

func (*Client) Fail

func (c *Client) Fail(ctx context.Context, projectId, jobId, elementId, errMessage string) error

func (*Client) FindDevice

func (c *Client) FindDevice(ctx context.Context, projectId, driverId, groupId, tableId, deviceId string, result interface{}) error

func (*Client) FindMachineCode

func (c *Client) FindMachineCode(ctx context.Context, result interface{}) error

func (*Client) FindTableCommandById

func (c *Client) FindTableCommandById(ctx context.Context, projectId, id string, result interface{}) error

func (*Client) FindTableDataCommandById

func (c *Client) FindTableDataCommandById(ctx context.Context, projectId, tableId, id string, result interface{}) error

func (*Client) FindTableDataDeptByDeptIDs

func (c *Client) FindTableDataDeptByDeptIDs(ctx context.Context, projectId string, ids map[string]interface{}, result interface{}) error

func (*Client) FindTagByID

func (c *Client) FindTagByID(ctx context.Context, projectId, tableId, id string, result interface{}) ([]byte, error)

func (*Client) FormulaDefaultSearch

func (c *Client) FormulaDefaultSearch(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) GetAPIKey

func (c *Client) GetAPIKey(ctx context.Context, projectId, id string, result interface{}) ([]byte, error)

func (*Client) GetAPIKeyByKeyID

func (c *Client) GetAPIKeyByKeyID(ctx context.Context, projectId, keyID string, result interface{}) ([]byte, error)

func (*Client) GetApp

func (c *Client) GetApp(ctx context.Context, projectId, id string, result interface{}) ([]byte, error)

func (*Client) GetBackup

func (c *Client) GetBackup(ctx context.Context, projectId, id string, result interface{}) ([]byte, error)

func (*Client) GetCatalog

func (c *Client) GetCatalog(ctx context.Context, projectId, id string, result interface{}) ([]byte, error)

func (*Client) GetCurrentUserInfo

func (c *Client) GetCurrentUserInfo(ctx context.Context, projectId, token string, result interface{}) error

func (*Client) GetDataRelayService

func (c *Client) GetDataRelayService(ctx context.Context, projectId, id string, result interface{}) ([]byte, error)

func (*Client) GetDept

func (c *Client) GetDept(ctx context.Context, projectId, id string, result interface{}) ([]byte, error)

func (*Client) GetDriverEventCron

func (c *Client) GetDriverEventCron(ctx context.Context, projectId, id string, result interface{}) ([]byte, error)

func (*Client) GetDriverInstance

func (c *Client) GetDriverInstance(ctx context.Context, projectId, id string, result interface{}) ([]byte, error)

func (*Client) GetDriverInstructCron

func (c *Client) GetDriverInstructCron(ctx context.Context, projectId, id string, result interface{}) ([]byte, error)

func (*Client) GetDriverLicense

func (c *Client) GetDriverLicense(ctx context.Context, projectId, driverId string, result interface{}) error

func (*Client) GetFileLicense

func (c *Client) GetFileLicense(ctx context.Context, result interface{}) error

func (*Client) GetFlow

func (c *Client) GetFlow(ctx context.Context, projectId, id string, result interface{}) ([]byte, error)

func (*Client) GetFlowJobCron

func (c *Client) GetFlowJobCron(ctx context.Context, projectId, id string, result interface{}) ([]byte, error)

func (*Client) GetFlowLogCron

func (c *Client) GetFlowLogCron(ctx context.Context, projectId, id string, result interface{}) ([]byte, error)

func (*Client) GetFlowTask

func (c *Client) GetFlowTask(ctx context.Context, projectId, id string, result interface{}) ([]byte, error)

func (*Client) GetLocalAlgorithm

func (c *Client) GetLocalAlgorithm(ctx context.Context, projectId, id string, result interface{}) ([]byte, error)

func (*Client) GetLog

func (c *Client) GetLog(ctx context.Context, projectId, id string, result interface{}) ([]byte, error)

func (*Client) GetMediaLibraryDirSetting

func (c *Client) GetMediaLibraryDirSetting(ctx context.Context, projectId, id string, result interface{}) ([]byte, error)

func (*Client) GetMediaLibraryDirSettingByPath

func (c *Client) GetMediaLibraryDirSettingByPath(ctx context.Context, projectId, path string, result interface{}) ([]byte, error)

func (*Client) GetProject

func (c *Client) GetProject(ctx context.Context, id string, result interface{}) ([]byte, error)

func (*Client) GetQuery

func (c *Client) GetQuery(ctx context.Context, projectId string, query, result interface{}) error

func (*Client) GetReport

func (c *Client) GetReport(ctx context.Context, projectId, id string, result interface{}) ([]byte, error)

func (*Client) GetRole

func (c *Client) GetRole(ctx context.Context, projectId, id string, result interface{}) ([]byte, error)

func (*Client) GetSync

func (c *Client) GetSync(ctx context.Context, projectId, id string, result interface{}) ([]byte, error)

func (*Client) GetSystemVariable

func (c *Client) GetSystemVariable(ctx context.Context, projectId, id string, result interface{}) ([]byte, error)

func (*Client) GetTableData

func (c *Client) GetTableData(ctx context.Context, projectId, tableName, id string, result interface{}) ([]byte, error)

func (*Client) GetTableDataByDB

func (c *Client) GetTableDataByDB(ctx context.Context, projectId, tableName, id string, result interface{}) ([]byte, error)

func (*Client) GetTableRecord

func (c *Client) GetTableRecord(ctx context.Context, projectId, id string, result interface{}) ([]byte, error)

func (*Client) GetTableSchema

func (c *Client) GetTableSchema(ctx context.Context, projectId, id string, result interface{}) ([]byte, error)

func (*Client) GetTaskManager

func (c *Client) GetTaskManager(ctx context.Context, projectId, id string, result interface{}) ([]byte, error)

func (*Client) GetToken

func (c *Client) GetToken() (string, error)

func (*Client) GetUser

func (c *Client) GetUser(ctx context.Context, projectId, id string, result interface{}) ([]byte, error)

func (*Client) GetWarn

func (c *Client) GetWarn(ctx context.Context, projectId, archive, id string, result interface{}) ([]byte, error)

func (*Client) GetWarningFilterIDs

func (c *Client) GetWarningFilterIDs(ctx context.Context, projectId, token string, result interface{}) error

func (*Client) HttpProxy

func (c *Client) HttpProxy(ctx context.Context, projectId, typeId, groupId string, headers, data, result interface{}) error

HttpProxy 驱动代理接口

func (*Client) ImportBackup

func (c *Client) ImportBackup(ctx context.Context, projectId string, query interface{}) (string, error)

func (*Client) LivePull2Ws

func (c *Client) LivePull2Ws(ctx context.Context, projectId string, createData interface{}) (string, error)

func (*Client) LiveStreamStopByStreamPath

func (c *Client) LiveStreamStopByStreamPath(ctx context.Context, projectId, streamPath string) error

func (*Client) LiveStreamsInfo

func (c *Client) LiveStreamsInfo(ctx context.Context, projectId string, result interface{}) error

func (*Client) MediaLibraryMkdir

func (c *Client) MediaLibraryMkdir(ctx context.Context, projectId string, catalog, dirName string) error

func (*Client) PostLatest

func (c *Client) PostLatest(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) PostQuery

func (c *Client) PostQuery(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) QueryAPIKey

func (c *Client) QueryAPIKey(ctx context.Context, projectId string, query, result interface{}) error

func (*Client) QueryApiPermissionLog

func (c *Client) QueryApiPermissionLog(ctx context.Context, projectId string, query, result interface{}) (int, error)

func (*Client) QueryApp

func (c *Client) QueryApp(ctx context.Context, projectId string, query, result interface{}) error

func (*Client) QueryBackup

func (c *Client) QueryBackup(ctx context.Context, projectId string, query, result interface{}, count *int64) error

func (*Client) QueryCatalog

func (c *Client) QueryCatalog(ctx context.Context, projectId string, query, result interface{}) error

func (*Client) QueryDashboard

func (c *Client) QueryDashboard(ctx context.Context, projectId string, query, result interface{}) (int, error)

func (*Client) QueryDataGroup

func (c *Client) QueryDataGroup(ctx context.Context, projectId string, query, result interface{}) (int64, error)

func (*Client) QueryDataInterface

func (c *Client) QueryDataInterface(ctx context.Context, projectId string, query, result interface{}) (int64, error)

func (*Client) QueryDataRelayService

func (c *Client) QueryDataRelayService(ctx context.Context, projectId string, query, result interface{}) error

func (*Client) QueryDataset

func (c *Client) QueryDataset(ctx context.Context, projectId string, query, result interface{}) (int64, error)

查询数据集整体配置(仅数据集本身),支持过滤和分页

func (*Client) QueryDatasetView

func (c *Client) QueryDatasetView(ctx context.Context, projectId string, query, result interface{}) (int64, error)

func (*Client) QueryDatasetWhole

func (c *Client) QueryDatasetWhole(ctx context.Context, projectId string, query, result interface{}) (int64, error)

查询数据集整体配置(包含数据集本身及其列配置),支持过滤和分页

func (*Client) QueryDept

func (c *Client) QueryDept(ctx context.Context, projectId string, query, result interface{}) error

func (*Client) QueryDriverEventCron

func (c *Client) QueryDriverEventCron(ctx context.Context, projectId string, query, result interface{}) error

func (*Client) QueryDriverInstance

func (c *Client) QueryDriverInstance(ctx context.Context, projectId string, query, result interface{}) error

func (*Client) QueryDriverInstructCron

func (c *Client) QueryDriverInstructCron(ctx context.Context, projectId string, query, result interface{}) error

func (*Client) QueryEmulator

func (c *Client) QueryEmulator(ctx context.Context, projectId string, result interface{}) error

func (*Client) QueryFlow

func (c *Client) QueryFlow(ctx context.Context, projectId string, query, result interface{}) (int, error)

QueryFlow Flow

func (*Client) QueryFlowJobCron

func (c *Client) QueryFlowJobCron(ctx context.Context, projectId string, query, result interface{}) error

func (*Client) QueryFlowLogCron

func (c *Client) QueryFlowLogCron(ctx context.Context, projectId string, query, result interface{}) error

func (*Client) QueryFlowTask

func (c *Client) QueryFlowTask(ctx context.Context, projectId string, query, result interface{}) (int, error)

func (*Client) QueryLocalAlgorithm

func (c *Client) QueryLocalAlgorithm(ctx context.Context, projectId string, query, result interface{}) error

func (*Client) QueryLog

func (c *Client) QueryLog(ctx context.Context, projectId string, query, result interface{}) (int, error)

func (*Client) QueryMediaLibrary

func (c *Client) QueryMediaLibrary(ctx context.Context, projectId string, catalog string, isFile, addBase64 bool, query, result interface{}) (int, error)

func (*Client) QueryMediaLibraryDirSetting

func (c *Client) QueryMediaLibraryDirSetting(ctx context.Context, projectId string, query, result interface{}) (int, error)

func (*Client) QueryMessage

func (c *Client) QueryMessage(ctx context.Context, projectId string, query, result interface{}) (int, error)

func (*Client) QueryOnlyTableSchemaDeviceByDriverAndGroup

func (c *Client) QueryOnlyTableSchemaDeviceByDriverAndGroup(ctx context.Context, projectId, driverId, groupId string, result interface{}) error

func (*Client) QueryPmSetting

func (c *Client) QueryPmSetting(ctx context.Context, query, result interface{}) error

func (*Client) QueryProject

func (c *Client) QueryProject(ctx context.Context, query, result interface{}) error

func (*Client) QueryProjectAvailable

func (c *Client) QueryProjectAvailable(ctx context.Context, result interface{}) error

func (*Client) QueryReport

func (c *Client) QueryReport(ctx context.Context, projectId string, query interface{}, result interface{}) (int, error)

QueryReport 查询

func (*Client) QueryReportCopy

func (c *Client) QueryReportCopy(ctx context.Context, projectId string, query interface{}, result interface{}) (int, error)

QueryReportCopy 查询

func (*Client) QueryRole

func (c *Client) QueryRole(ctx context.Context, projectId string, query, result interface{}) error

func (*Client) QueryRule

func (c *Client) QueryRule(ctx context.Context, projectId string, query interface{}, result interface{}) (int, error)

QueryRule 查询

func (*Client) QuerySetting

func (c *Client) QuerySetting(ctx context.Context, projectId string, query, result interface{}) error

func (*Client) QuerySync

func (c *Client) QuerySync(ctx context.Context, projectId string, query, result interface{}) (int, error)

QuerySync Sync

func (*Client) QuerySyslog

func (c *Client) QuerySyslog(ctx context.Context, projectId string, query, result interface{}) (int, error)

QuerySyslog Syslog

func (*Client) QuerySystemVariable

func (c *Client) QuerySystemVariable(ctx context.Context, projectId string, query, result interface{}) error

func (*Client) QueryTableData

func (c *Client) QueryTableData(ctx context.Context, projectId, tableName string, query, result interface{}) (int64, error)

func (*Client) QueryTableDataByDB

func (c *Client) QueryTableDataByDB(ctx context.Context, projectId, tableName string, query, result interface{}) (int64, error)

func (*Client) QueryTableDataByTableId

func (c *Client) QueryTableDataByTableId(ctx context.Context, projectId, tableId string, query, result interface{}) error

func (*Client) QueryTableRecord

func (c *Client) QueryTableRecord(ctx context.Context, projectId string, query, result interface{}) (int64, error)

func (*Client) QueryTableSchema

func (c *Client) QueryTableSchema(ctx context.Context, projectId string, query, result interface{}) error

func (*Client) QueryTableSchemaDeviceByDriverAndGroup

func (c *Client) QueryTableSchemaDeviceByDriverAndGroup(ctx context.Context, projectId, driverId, groupId string, result interface{}) error

func (*Client) QueryTaskManager

func (c *Client) QueryTaskManager(ctx context.Context, projectId string, query, result interface{}) error

func (*Client) QueryUser

func (c *Client) QueryUser(ctx context.Context, projectId string, query, result interface{}) error

func (*Client) QueryUserBackup

func (c *Client) QueryUserBackup(ctx context.Context, projectId string, query, result interface{}) error

func (*Client) QueryWarn

func (c *Client) QueryWarn(ctx context.Context, projectId, token, archive string, query interface{}, result interface{}) (int, error)

QueryWarn 查询

func (*Client) ReplaceDataGroup

func (c *Client) ReplaceDataGroup(ctx context.Context, projectId, id string, createData interface{}) error

func (*Client) ReplaceDataInterface

func (c *Client) ReplaceDataInterface(ctx context.Context, projectId, id string, createData interface{}) error

func (*Client) ReplaceDataRelayService

func (c *Client) ReplaceDataRelayService(ctx context.Context, projectId, id string, updateData, result interface{}) error

func (*Client) ReplaceDatasetView

func (c *Client) ReplaceDatasetView(ctx context.Context, projectId, id string, datasetView interface{}) error

func (*Client) ReplaceDatasetWhole

func (c *Client) ReplaceDatasetWhole(ctx context.Context, projectId, id string, datasetWhole interface{}) error

func (*Client) ReplaceDriverEventCron

func (c *Client) ReplaceDriverEventCron(ctx context.Context, projectId, id string, updateData interface{}) error

func (*Client) ReplaceDriverInstance

func (c *Client) ReplaceDriverInstance(ctx context.Context, projectId, id string, updateData, result interface{}) error

func (*Client) ReplaceDriverInstructCron

func (c *Client) ReplaceDriverInstructCron(ctx context.Context, projectId, id string, updateData interface{}) error

func (*Client) ReplaceFlow

func (c *Client) ReplaceFlow(ctx context.Context, projectId, id string, updateData, result interface{}) error

func (*Client) ReplaceFlowJobCron

func (c *Client) ReplaceFlowJobCron(ctx context.Context, projectId, id string, updateData interface{}) error

func (*Client) ReplaceFlowTask

func (c *Client) ReplaceFlowTask(ctx context.Context, projectId, id string, updateData, result interface{}) error

func (*Client) ReplaceLocalAlgorithm

func (c *Client) ReplaceLocalAlgorithm(ctx context.Context, projectId, id string, updateData interface{}) error

func (*Client) ReplaceMediaLibraryDirSetting

func (c *Client) ReplaceMediaLibraryDirSetting(ctx context.Context, projectId, id string, updateData, result interface{}) error

func (*Client) ReplaceProject

func (c *Client) ReplaceProject(ctx context.Context, id string, updateData, result interface{}) error

func (*Client) ReplaceReport

func (c *Client) ReplaceReport(ctx context.Context, projectId, id string, updateData, result interface{}) error

func (*Client) ReplaceReportCopy

func (c *Client) ReplaceReportCopy(ctx context.Context, projectId, id string, updateData, result interface{}) error

func (*Client) ReplaceRule

func (c *Client) ReplaceRule(ctx context.Context, projectId, id string, updateData, result interface{}) error

func (*Client) ReplaceSync

func (c *Client) ReplaceSync(ctx context.Context, projectId, id string, updateData, result interface{}) error

func (*Client) ReplaceSystemVariable

func (c *Client) ReplaceSystemVariable(ctx context.Context, projectId, id string, updateData, result interface{}) error

func (*Client) ReplaceTableData

func (c *Client) ReplaceTableData(ctx context.Context, projectId, tableName, id string, closeRequire bool, updateData, result interface{}) error

func (*Client) ReplaceTableDataByDB

func (c *Client) ReplaceTableDataByDB(ctx context.Context, projectId, tableName, id string, updateData, result interface{}) error

func (*Client) ReplaceTableRecord

func (c *Client) ReplaceTableRecord(ctx context.Context, projectId, id string, updateData, result interface{}) error

func (*Client) ReplaceTableSchema

func (c *Client) ReplaceTableSchema(ctx context.Context, projectId, id string, updateData, result interface{}) error

func (*Client) ReplaceTaskManager

func (c *Client) ReplaceTaskManager(ctx context.Context, projectId, id string, updateData, result interface{}) error

func (*Client) ReplaceUser

func (c *Client) ReplaceUser(ctx context.Context, projectId, id string, updateData, result interface{}) error

func (*Client) RestQueryProject

func (c *Client) RestQueryProject(ctx context.Context, query, result interface{}) error

func (*Client) RestQueryTableSchema

func (c *Client) RestQueryTableSchema(ctx context.Context, projectId string, query, result interface{}) error

func (*Client) Resume

func (c *Client) Resume(ctx context.Context, projectId, jobId, elementId string, variables map[string]interface{}) error

func (*Client) Revert

func (c *Client) Revert(ctx context.Context, projectId, jobId, elementId string, variables map[string]interface{}) error

func (*Client) RevertCreateFlowTask

func (c *Client) RevertCreateFlowTask(ctx context.Context, projectId string, createData, result interface{}) error

func (*Client) RtspPull

func (c *Client) RtspPull(ctx context.Context, projectId string, createData interface{}) (string, error)

func (*Client) Run

func (c *Client) Run(ctx context.Context, projectId, flowConfig string, elementB []byte, variables map[string]interface{}) (result *engine.RunResponse, err error)

func (*Client) RunJsScript

func (c *Client) RunJsScript(ctx context.Context, variables interface{}, script string) ([]byte, error)

func (*Client) StatsQuery

func (c *Client) StatsQuery(ctx context.Context, projectId string, query, result interface{}) error

func (*Client) UpdateBackup

func (c *Client) UpdateBackup(ctx context.Context, projectId, id string, updateData, result interface{}) error

func (*Client) UpdateDataGroup

func (c *Client) UpdateDataGroup(ctx context.Context, projectId, id string, createData interface{}) error

func (*Client) UpdateDataInterface

func (c *Client) UpdateDataInterface(ctx context.Context, projectId, id string, createData interface{}) error

func (*Client) UpdateDataRelayService

func (c *Client) UpdateDataRelayService(ctx context.Context, projectId, id string, updateData, result interface{}) error

func (*Client) UpdateDriverEventCron

func (c *Client) UpdateDriverEventCron(ctx context.Context, projectId, id string, updateData interface{}) error

func (*Client) UpdateDriverInstance

func (c *Client) UpdateDriverInstance(ctx context.Context, projectId, id string, updateData, result interface{}) error

func (*Client) UpdateDriverInstructCron

func (c *Client) UpdateDriverInstructCron(ctx context.Context, projectId, id string, updateData interface{}) error

func (*Client) UpdateFlow

func (c *Client) UpdateFlow(ctx context.Context, projectId, id string, updateData, result interface{}) error

func (*Client) UpdateFlowJobCron

func (c *Client) UpdateFlowJobCron(ctx context.Context, projectId, id string, updateData interface{}) error

func (*Client) UpdateFlowLogCron

func (c *Client) UpdateFlowLogCron(ctx context.Context, projectId, id string, updateData interface{}) error

func (*Client) UpdateFlowTask

func (c *Client) UpdateFlowTask(ctx context.Context, projectId, id string, updateData, result interface{}) error

func (*Client) UpdateFlowTaskFilter

func (c *Client) UpdateFlowTaskFilter(ctx context.Context, projectId string, query, updateData interface{}) error

func (*Client) UpdateLocalAlgorithm

func (c *Client) UpdateLocalAlgorithm(ctx context.Context, projectId, id string, updateData interface{}) error

func (*Client) UpdateManyTableData

func (c *Client) UpdateManyTableData(ctx context.Context, projectId, tableName string, closeRequire bool, query, updateData, result interface{}) error

func (*Client) UpdateManyTableDataByDB

func (c *Client) UpdateManyTableDataByDB(ctx context.Context, projectId, tableName string, updateDataList, result interface{}) error

func (*Client) UpdateMediaLibraryDirSetting

func (c *Client) UpdateMediaLibraryDirSetting(ctx context.Context, projectId, id string, updateData, result interface{}) error

func (*Client) UpdateProject

func (c *Client) UpdateProject(ctx context.Context, id string, updateData, result interface{}) error

func (*Client) UpdateProjectLicense

func (c *Client) UpdateProjectLicense(ctx context.Context, id string, updateData, _ interface{}) error

func (*Client) UpdateReport

func (c *Client) UpdateReport(ctx context.Context, projectId, id string, updateData, result interface{}) error

func (*Client) UpdateReportCopy

func (c *Client) UpdateReportCopy(ctx context.Context, projectId, id string, updateData, result interface{}) error

func (*Client) UpdateRule

func (c *Client) UpdateRule(ctx context.Context, projectId, id string, updateData, result interface{}) error

func (*Client) UpdateSync

func (c *Client) UpdateSync(ctx context.Context, projectId, id string, updateData, result interface{}) error

func (*Client) UpdateSystemVariable

func (c *Client) UpdateSystemVariable(ctx context.Context, projectId, id string, updateData, result interface{}) error

func (*Client) UpdateTableData

func (c *Client) UpdateTableData(ctx context.Context, projectId, tableName, id string, closeRequire bool, updateData, result interface{}) error

func (*Client) UpdateTableDataByDB

func (c *Client) UpdateTableDataByDB(ctx context.Context, projectId, tableName, id string, updateData, result interface{}) error

func (*Client) UpdateTableRecord

func (c *Client) UpdateTableRecord(ctx context.Context, projectId, id string, updateData, result interface{}) error

func (*Client) UpdateTableSchema

func (c *Client) UpdateTableSchema(ctx context.Context, projectId, id string, updateData, result interface{}) error

func (*Client) UpdateTaskManager

func (c *Client) UpdateTaskManager(ctx context.Context, projectId, id string, updateData, result interface{}) error

func (*Client) UpdateUser

func (c *Client) UpdateUser(ctx context.Context, projectId, id string, updateData, result interface{}) error

func (*Client) UploadBackup

func (c *Client) UploadBackup(ctx context.Context, projectId, password string, size int, r io.Reader) error

func (*Client) UploadFile

func (c *Client) UploadFile(ctx context.Context, projectId string, mediaLibraryPath, saveFileName, action, uploadFile string) (string, error)

UploadFile 上传文件到媒体库

projectId: 项目ID mediaLibraryPath: 媒体库目录 saveFileName: 保存文件名 action: 文件重复时的行为处理方式. cover: 覆盖, rename: 文件名自动加1 uploadFile: 本地待上传的文件路径

返回值: 文件访问地址, 错误

func (*Client) UploadFileData

func (c *Client) UploadFileData(ctx context.Context, projectId string, mediaLibraryPath, saveFileName, action string, reader io.Reader) (string, error)

UploadFileData 上传文件到媒体库

projectId: 项目ID mediaLibraryPath: 媒体库目录 saveFileName: 保存文件名 action: 文件重复时的行为处理方式. cover: 覆盖, rename: 文件名自动加1 reader: 上传文件的 io.Reader

返回值: 文件访问地址, 错误

func (*Client) UploadFileFromBase64

func (c *Client) UploadFileFromBase64(ctx context.Context, projectId string, base64Str, mediaLibraryPath, saveFileName, action string) (string, float64, error)

func (*Client) UploadFileFromUrl

func (c *Client) UploadFileFromUrl(ctx context.Context, projectId string, sourceUrl string, catalog string, filename string, action string, addBase64 bool) (string, string, float64, error)

UploadFileFromUrl 将远程文件上传到媒体库

sourceUrl 远程文件的下载 url

catalog 上传到媒体库的目录

filename 上传到媒体库后的文件名

上传成功后返回文件的访问地址,base64字符串,文件大小,错误

func (*Client) UploadLicense

func (c *Client) UploadLicense(ctx context.Context, projectId, filename string, size int, r io.Reader) error

func (*Client) UseLicense

func (c *Client) UseLicense(ctx context.Context, projectId string, result interface{}) error

func (*Client) UserPermissionUpdate

func (c *Client) UserPermissionUpdate(ctx context.Context, projectId, token string, createData, result interface{}) error

type ConditionField

type ConditionField struct {
	Name  string      `json:"name"`  // 字段名
	Value interface{} `json:"value"` // 值
	Op    string      `json:"op"`    // 符号
}

ConditionField

@Description	视图查询条件,如 name = value

type DriverBatchWriteTag

type DriverBatchWriteTag struct {
	TableId      string      `json:"tableId"`
	TableDataIds []string    `json:"tableDataIds"`
	ID           string      `json:"id" bson:"id"`
	Query        string      `json:"query"`
	Type         string      `json:"type"`
	Params       interface{} `json:"params" bson:"params"`
}

type DriverWriteTag

type DriverWriteTag struct {
	Table     string      `json:"table"`
	TableData string      `json:"tableData"`
	ID        string      `json:"id" bson:"id"`
	Params    interface{} `json:"params" bson:"params"`
}

type Handler

type Handler func(param Params, data []byte) (map[string]interface{}, error)

type KratosRegistryClient

type KratosRegistryClient struct {
	// contains filtered or unexported fields
}

func NewKartosRegistryClient

func NewKartosRegistryClient(cli *clientv3.Client, options ...etcd.Option) *KratosRegistryClient

func (*KratosRegistryClient) GetServiceEndpoints

func (reg *KratosRegistryClient) GetServiceEndpoints(serviceInstances []*registry.ServiceInstance, schemes ...string) []string

GetServiceEndpoints 获取服务实例的指定协议的端点. 如果 schemes 为空, 则返回所有端点

serviceInstances: 服务实例列表

schemes: 协议列表, 例如: http, https, grpc 等. 如果为空, 则返回所有端点. 如果不为空, 则返回指定协议的端点

func (*KratosRegistryClient) GetServiceEndpointsByServiceName

func (reg *KratosRegistryClient) GetServiceEndpointsByServiceName(ctx context.Context, serviceName string, allowEmptyEnv bool, envs []string, schemes []string) ([]string, error)

GetServiceEndpointsByServiceName 从注册中心查询指定服务的实例列表, 并获取指定协议的端点

serviceName: 服务名称

allowEmptyEnv: 是否允许环境为空的实例. 如果为 true, 则返回的实例列表中包含未定义 env 元数据或者 env 为空的实例

envs: 环境列表. 如果为空, 则返回所有实例. 如果不为空, 则返回指定环境的实例

schemes: 协议列表, 例如: http, https, grpc 等. 如果为空, 则返回所有端点. 如果不为空, 则返回指定协议的端点

func (*KratosRegistryClient) GetServiceInstances

func (reg *KratosRegistryClient) GetServiceInstances(ctx context.Context, serviceName string, allowEmptyEnv bool, envs ...string) ([]*registry.ServiceInstance, error)

GetServiceInstances 从注册中心查询指定服务的实例列表. 可以通过 env 过滤服务实例

serviceName: 服务名称

allowEmptyEnv: 是否允许环境为空的实例. 如果为 true, 则返回的实例列表中包含未定义 env 元数据或者 env 为空的实例

envs: 环境列表. 如果为空, 则返回所有实例. 如果不为空, 则返回指定环境的实例

func (*KratosRegistryClient) Watch

func (reg *KratosRegistryClient) Watch(ctx context.Context, serviceName string, options ...WatchOption) (*KratosRegistryWatchClient, error)

type KratosRegistryWatchClient

type KratosRegistryWatchClient struct {
	// contains filtered or unexported fields
}

func (*KratosRegistryWatchClient) Error

func (rwc *KratosRegistryWatchClient) Error() error

func (*KratosRegistryWatchClient) GetServiceEndpointsByServiceName

func (rwc *KratosRegistryWatchClient) GetServiceEndpointsByServiceName(schemes ...string) ([]string, error)

func (*KratosRegistryWatchClient) GetServiceInstances

func (rwc *KratosRegistryWatchClient) GetServiceInstances() ([]*registry.ServiceInstance, error)

type MediaFile

type MediaFile struct {
	Name string `json:"name"`
	Url  string `json:"url"`
}

MediaFile 媒体库文件

type MultipartReader

type MultipartReader struct {
	// contains filtered or unexported fields
}

func NewMultipart

func NewMultipart(fieldName, filename string, reader io.Reader) (*MultipartReader, error)

func (*MultipartReader) FormDataContentType

func (m *MultipartReader) FormDataContentType() string

func (*MultipartReader) Read

func (m *MultipartReader) Read(p []byte) (n int, err error)

type OrderByField

type OrderByField struct {
	Name string `json:"name"`           // 字段名
	Desc bool   `json:"desc,omitempty"` // 是否降序,默认升序
}

OrderByField @Description 视图排序

type Params

type Params struct {
	ProjectId  string `json:"projectId"`
	FlowId     string `json:"flowId"`
	Job        string `json:"job"`
	ElementId  string `json:"elementId"`
	ElementJob string `json:"elementJob"`
}

type ProxyResult

type ProxyResult struct {
	Code    int32  `json:"code"`
	Headers []byte `json:"headers"`
	Body    []byte `json:"body"`
}

type QueryParam

type QueryParam struct {
	Fields     []SelectField  `json:"fields,omitempty"` // 包含查询列(原始列originalName或id)、别名和聚合方法
	Where      WhereFilter    `json:"where,omitempty"`  // 查询条件
	Group      []string       `json:"group,omitempty"`  // 聚合的列(原始列的originalName或id)
	Limit      *uint          `json:"limit,omitempty"`  // 查询结果的最大条数
	Offset     *uint          `json:"offset,omitempty"` // 查询结果的偏移量
	Order      []OrderByField `json:"order,omitempty"`  // 排序
	EchartType string         `json:"echartType"`
	NoGroupBy  bool           `json:"noGroupBy"`            // false: groups和stack里的维度字段都会被group by
	Stack      []string       `json:"stack,omitempty"`      // 字段id
	Drill      []string       `json:"drill,omitempty"`      // 下钻,字段id
	GroupAlias []string       `json:"groupAlias,omitempty"` // 聚合字段别名
}

type SelectField

type SelectField struct {
	Name   string             `json:"name"`             // 数据集的列的列名,使用count函数聚合时不写
	Alias  string             `json:"alias,omitempty"`  // 别名
	Option *SelectFieldOption `json:"option,omitempty"` // 聚合的列需要加上option
}

SelectField @Description 视图查询的列

type SelectFieldOption

type SelectFieldOption struct {
	Aggregator   string          `json:"aggregator" example:"max"` // 聚合函数
	DefaultValue interface{}     `json:"defaultValue,omitempty"`   // 默认值
	Distinct     bool            `json:"distinct,omitempty"`       // 是否去重
	Filter       *ConditionField `json:"filter,omitempty"`         // having过滤
}

SelectFieldOption model info

@Description	查询选项
@Description	如果列涉及到聚合,在选项中配置聚合函

type Service

type Service struct {
	ServiceCaches *gocache.Cache
	// contains filtered or unexported fields
}

func (*Service) IsExist

func (c *Service) IsExist(ctx context.Context, serviceName string) (bool, error)

type TaskMode

type TaskMode int32
const (
	USER    TaskMode = 0
	SERVICE TaskMode = 1
)

func (TaskMode) String

func (p TaskMode) String() string

type WatchOption

type WatchOption interface {
	Apply(options *watchOptions)
}

type WatchOptionFn

type WatchOptionFn func(options *watchOptions)

func WithAllowEmptyEnv

func WithAllowEmptyEnv(allowEmptyEnv bool) WatchOptionFn

func WithEnvs

func WithEnvs(envs ...string) WatchOptionFn

func WithReconnectInterval

func WithReconnectInterval(interval time.Duration) WatchOptionFn

func (WatchOptionFn) Apply

func (f WatchOptionFn) Apply(options *watchOptions)

type WhereConditions

type WhereConditions struct {
	Conditions []ConditionField `json:"conditions"`
	// 不同条件之间的关系,false: and, true: or
	OR bool `json:"or,omitempty"`
}

WhereConditions 只为兼容原配置保留,不再使用

type WhereFilter

type WhereFilter [][]ConditionField

@Description 视图所有查询条件组,第一级的条件为或关系,第二级的条件为与关系

func (*WhereFilter) UnmarshalJSON

func (wf *WhereFilter) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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