gateway

package
v1.2.0-beta Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProfessionOutput      = "output"
	ProfessionCertificate = "certificate"
	ProfessionRouter      = "router"
	ProfessionApplication = "app"
	ProfessionService     = "service"
	ProfessionAIProvider  = "ai-provider"
)

Variables

This section is empty.

Functions

func Drivers

func Drivers() []string

func InitGateway

func InitGateway(ctx context.Context, clusterId string, client IClientDriver) (err error)

func Register

func Register(name string, factory IFactory)

func RegisterDynamicResourceDriver

func RegisterDynamicResourceDriver(key string, worker Worker)

func RegisterInitHandleFunc

func RegisterInitHandleFunc(handleFunc InitHandleFunc)

func RegisterInitHandler

func RegisterInitHandler(handle InitHandler)

Types

type ApiRelease

type ApiRelease struct {
	*BasicItem
	Path      string
	Methods   []string
	Host      []string
	Protocols []string

	Plugins      map[string]*Plugin
	Service      string
	Rules        []*MatchRule
	Extends      map[string]any
	ProxyPath    string
	ProxyHeaders []*ProxyHeader
	Retry        int
	Timeout      int

	Labels  map[string]string
	Disable bool
}

type ApplicationRelease

type ApplicationRelease struct {
	*BasicItem
	Labels         map[string]string
	Authorizations []*Authorization
}

type AuthConfig

type AuthConfig struct {
	// 认证类型
	Type string
	// 认证信息
	Info map[string]interface{}
}

type Authorization

type Authorization struct {
	Type           string
	Position       string
	TokenName      string
	Expire         int64
	Config         map[string]interface{}
	Label          map[string]string
	HideCredential bool
}

type BasicItem

type BasicItem struct {
	ID          string
	Description string
	Version     string
	Resource    string
	MatchLabels map[string]string
}

type ClientConfig

type ClientConfig struct {
	// 请求地址列表
	Addresses []string
	// 认证配置
	Auth *AuthConfig
}

type DynamicRelease

type DynamicRelease struct {
	*BasicItem
	Attr map[string]interface{}
}

func (*DynamicRelease) UnmarshalJSON

func (d *DynamicRelease) UnmarshalJSON(bytes []byte) error

type FactoryManager

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

func (*FactoryManager) Drivers

func (f *FactoryManager) Drivers() []string

func (*FactoryManager) GetClient

func (f *FactoryManager) GetClient(name string, config *ClientConfig) (IClientDriver, error)

func (*FactoryManager) Set

func (f *FactoryManager) Set(name string, factory IFactory)

type IClientDriver

type IClientDriver interface {
	Project() IProjectClient
	Application() IApplicationClient
	Service() IServiceClient
	Subscribe() ISubscribeClient
	Dynamic(resource string) (IDynamicClient, error)
	PluginSetting() IPluginSetting
	Commit(ctx context.Context) error
	Rollback(ctx context.Context) error
	Begin(ctx context.Context) error
	Close(ctx context.Context) error
}

func GetClient

func GetClient(name string, config *ClientConfig) (IClientDriver, error)

type IDynamicClient

type IDynamicClient interface {
	IResourceClient[DynamicRelease]
	Versions(ctx context.Context, matchLabels map[string]string) (map[string]string, error)
	Version(ctx context.Context, resourceId string) (string, error)
}

type IFactory

type IFactory interface {
	Create(config *ClientConfig) (IClientDriver, error)
}

type IFactoryManager

type IFactoryManager interface {
	Set(name string, factory IFactory)
	GetClient(name string, config *ClientConfig) (IClientDriver, error)
	Drivers() []string
}

func NewFactoryManager

func NewFactoryManager() IFactoryManager

type IPluginSetting

type IPluginSetting interface {
	Init(ctx context.Context) error
	Set(ctx context.Context, cfgs []*PluginConfig) error
}

type IProjectClient

type IProjectClient IResourceClient[ProjectRelease]

type IResourceClient

type IResourceClient[T any] interface {
	Online(ctx context.Context, resources ...*T) error
	Offline(ctx context.Context, resources ...*T) error
}

type IServiceClient

type IServiceClient IResourceClient[ServiceRelease]

type ISubscribeClient

type ISubscribeClient IResourceClient[SubscribeRelease]

type InitHandleFunc

type InitHandleFunc func(ctx context.Context, clusterId string, client IClientDriver) error

func (InitHandleFunc) Init

func (f InitHandleFunc) Init(ctx context.Context, clusterId string, client IClientDriver) error

type InitHandler

type InitHandler interface {
	Init(ctx context.Context, clusterId string, client IClientDriver) error
}

type MatchRule

type MatchRule struct {
	Position  string
	MatchType string
	Key       string
	Pattern   string
}

type Plugin

type Plugin struct {
	Disable bool
	Config  plugin_model.ConfigType
}

type PluginConfig

type PluginConfig struct {
	Id     string                 `json:"id"`
	Name   string                 `json:"name"`
	Status string                 `json:"status"`
	Config map[string]interface{} `json:"config"`
}

type ProjectRelease

type ProjectRelease struct {
	Id       string           `json:"id"`
	Version  string           `json:"version"`
	Apis     []*ApiRelease    `json:"apis"`
	Upstream *UpstreamRelease `json:"upstreams"`
}

type ProxyHeader

type ProxyHeader struct {
	Key   string `json:"key"`
	Value string `json:"value"`
	Opt   string `json:"opt"`
}

type ServiceRelease

type ServiceRelease struct {
	ID   string
	Apis []string
}

type SubscribeRelease

type SubscribeRelease struct {
	// 订阅服务ID
	Service string
	// 订阅方ID
	Application string
	// 过期时间
	Expired string
}

type UpstreamRelease

type UpstreamRelease struct {
	*BasicItem
	Nodes    []string
	PassHost string
	Scheme   string
	// Discovery 服务发现ID
	Discovery string
	// Service 服务发现服务名
	Service string
	Balance string
	Timeout int
	Labels  map[string]string
}

type Worker

type Worker struct {
	Profession string
	Driver     string
}

func GetDynamicResourceDriver

func GetDynamicResourceDriver(key string) (Worker, bool)

Directories

Path Synopsis
extends
处理cors扩展, 对启用了cors的api,添加 cors信息 从apinto移除api时, 移除对应的cors信息
处理cors扩展, 对启用了cors的api,添加 cors信息 从apinto移除api时, 移除对应的cors信息

Jump to

Keyboard shortcuts

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