data_relay

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MODULE_STARTSERVICE string = "运行服务"
	MODULE_HEALTHCHECK         = "健康检查"
	MODULE_START               = "启动服务"
	MODULE_HTTPPROXY           = "Http代理"
)

Variables

View Source
var Cfg = new(Config)

Cfg 全局配置(需要先执行MustLoad,否则拿不到配置)

Functions

func Init

func Init()

Types

type App

type App interface {
	Start(ext DataRelay)
	GetProjectId() string
	GetAPIClient() *api_client_go.Client
	GetMQ() mq.MQ
}

func NewApp

func NewApp() App

NewApp 创建App

type Client

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

func (*Client) HttpProxyStream

func (c *Client) HttpProxyStream(ctx context.Context) error

func (*Client) Start

func (c *Client) Start(app App, service DataRelay) *Client

func (*Client) StartStream

func (c *Client) StartStream(ctx context.Context) error

func (*Client) Stop

func (c *Client) Stop()

type Config

type Config struct {
	Log        logger.Config `json:"log" yaml:"log"`
	InstanceID string        `json:"instanceId" yaml:"instanceId" mapstructure:"instanceId"`
	Project    string        `json:"project" yaml:"project" mapstructure:"project"`
	Service    struct {
		ID   string `json:"id" yaml:"id"`
		Name string `json:"name" yaml:"name"`
	} `json:"service" yaml:"service"`
	DataRelayGrpc grpc.Config `json:"dataRelayGrpc" yaml:"dataRelayGrpc"`
	Pprof         struct {
		Enable bool   `json:"enable" yaml:"enable"`
		Host   string `json:"host" yaml:"host"`
		Port   string `json:"port" yaml:"port"`
	} `json:"pprof" yaml:"pprof"`
	EtcdConfig string      `json:"etcdConfig" yaml:"etcdConfig"`
	Etcd       etcd.Config `json:"etcd" yaml:"etcd"`
	App        struct {
		API grpcConfig.Config `json:"api" yaml:"API"`
	} `json:"app" yaml:"app"`
	MQ  mq.Config         `json:"mq" yaml:"mq"`
	API grpcConfig.Config `json:"api" yaml:"api"`
}

type DataRelay

type DataRelay interface {

	// Start
	// @description 启动服务
	// @param driverConfig "配置数据"
	Start(ctx context.Context, app App, config []byte) (err error)

	// HttpProxy
	// @description 代理接口
	// @param t 请求接口标识
	// @param header 请求头
	// @param data 请求数据
	// @return result "响应结果,自定义返回的格式"
	HttpProxy(ctx context.Context, app App, t string, header http.Header, data []byte) (result []byte, err error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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