Documentation
¶
Index ¶
- Constants
- Variables
- func Adapter(cfg *model.Bootstrap) (err error)
- func CheckYamlFormat(path string) bool
- func GetBootstrap() *model.Bootstrap
- func GetDiscoveryType(cfg *model.Bootstrap) (err error)
- func GetHttpConfig(cfg *model.Bootstrap) (err error)
- func GetLoadBalance(cfg *model.Bootstrap) (err error)
- func GetProtocol(cfg *model.Bootstrap) (err error)
- func Load(path string) *model.Bootstrap
- func LoadYAMLConfig(path string) *model.Bootstrap
- func RegisterConfigListener(li APIConfigResourceListener)
- func RegisterConfigLoadFunc(f LoadFunc)
- type APIConfig
- type APIConfigResourceListener
- type BodyDefinition
- type Cluster
- type ConfigManager
- type Definition
- type DubboBackendConfig
- type Filter
- type HTTPBackendConfig
- type HTTPFilters
- type InboundRequest
- type IntegrationRequest
- type Listener
- type LoadFunc
- type MappingParam
- type Method
- type Params
- type Resource
- type RouteConfig
Constants ¶
const DefaultTimeoutStr = "1s"
const (
// Version TODO: delete this if not used in the future
Version = "0.4.0"
)
Variables ¶
var ( BASE_INFO_NAME = "name" BASE_INFO_DESC = "description" )
Functions ¶
func CheckYamlFormat ¶
func GetBootstrap ¶
GetBootstrap get config global, need a better name
func GetDiscoveryType ¶
func GetHttpConfig ¶
func GetLoadBalance ¶
func GetProtocol ¶
func LoadYAMLConfig ¶
LoadYAMLConfig YAMLConfigLoad config load yaml
func RegisterConfigListener ¶
func RegisterConfigListener(li APIConfigResourceListener)
RegisterConfigListener register APIConfigListener
func RegisterConfigLoadFunc ¶
func RegisterConfigLoadFunc(f LoadFunc)
RegisterConfigLoadFunc can replace a new config load function instead of default
Types ¶
type APIConfig ¶ added in v1.1.0
type APIConfig struct {
Name string `json:"name" yaml:"name"`
Description string `json:"description" yaml:"description"`
Resources []Resource `json:"resources" yaml:"resources"`
Definitions []Definition `json:"definitions" yaml:"definitions"`
}
APIConfig defines the data structure of the api gateway configuration
func LoadAPIConfig ¶
func LoadAPIConfig(metaConfig *model.APIMetaConfig) (*APIConfig, error)
LoadAPIConfig load the api config from config center
func LoadAPIConfigFromFile ¶
LoadAPIConfigFromFile load the api config from file
type APIConfigResourceListener ¶ added in v1.1.0
type APIConfigResourceListener interface {
// ResourceChange handle modify resource event
ResourceChange(new Resource, old Resource) bool // bool is return for interface implement is interesting
// ResourceAdd handle add resource event
ResourceAdd(res Resource) bool
// ResourceDelete handle delete resource event
ResourceDelete(deleted Resource) bool
// MethodChange handle modify method event
MethodChange(res Resource, method Method, old Method) bool
// MethodAdd handle add method below one resource event
MethodAdd(res Resource, method Method) bool
// MethodDelete handle delete method event
MethodDelete(res Resource, method Method) bool
}
APIConfigResourceListener defines api resource and method config listener interface
type BodyDefinition ¶ added in v1.1.0
type BodyDefinition struct {
DefinitionName string `json:"definitionName" yaml:"definitionName"`
}
BodyDefinition connects the request body to the definitions
type Cluster ¶ added in v1.1.0
type Cluster struct {
Name string `json:"name,omitempty" yaml:"name"` // cluster name
Type string `json:"type,omitempty" yaml:"type"` // cluster type
Address string `json:"address,omitempty" yaml:"address"` // cluster address
Port int `json:"port,omitempty" yaml:"port"` // cluster port
ID int `json:"id,omitempty" yaml:"id"` // cluster id
}
Cluster defines the cluster config
type ConfigManager ¶ added in v1.1.0
type ConfigManager struct {
// contains filtered or unexported fields
}
func NewConfigManger ¶ added in v1.1.0
func NewConfigManger() *ConfigManager
func (*ConfigManager) LoadBootConfig ¶ added in v1.1.0
func (m *ConfigManager) LoadBootConfig(path string) *model.Bootstrap
func (*ConfigManager) ViewRemoteConfig ¶ added in v1.1.0
func (m *ConfigManager) ViewRemoteConfig() *model.Bootstrap
ViewRemoteConfig returns the current remote configuration.
type Definition ¶ added in v1.1.0
type Definition struct {
Name string `json:"name" yaml:"name"`
Schema string `json:"schema" yaml:"schema"` // use json schema
}
Definition defines the complex json request body
type DubboBackendConfig ¶ added in v1.1.0
type DubboBackendConfig struct {
ClusterName string `yaml:"clusterName" json:"clusterName"`
ApplicationName string `yaml:"applicationName" json:"applicationName"`
Protocol string `yaml:"protocol" json:"protocol,omitempty" default:"dubbo"`
Group string `yaml:"group" json:"group"`
Version string `yaml:"version" json:"version"`
Interface string `yaml:"interface" json:"interface"`
Method string `yaml:"method" json:"method"`
Retries string `yaml:"retries" json:"retries,omitempty"`
}
DubboBackendConfig defines the basic dubbo backend config
type Filter ¶ added in v1.1.0
type Filter struct {
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Config map[string]any `json:"config,omitempty" yaml:"config,omitempty" `
}
Filter filter with config
type HTTPBackendConfig ¶ added in v1.1.0
type HTTPBackendConfig struct {
URL string `yaml:"url" json:"url,omitempty"`
// downstream host.
Host string `yaml:"host" json:"host,omitempty"`
// path to replace.
Path string `yaml:"path" json:"path,omitempty"`
// http protocol, http or https.
Schema string `yaml:"schema" json:"scheme,omitempty"`
}
HTTPBackendConfig defines the basic dubbo backend config
type HTTPFilters ¶ added in v1.1.0
type HTTPFilters []struct {
Name string `yaml:"name" json:"name"`
Config any `yaml:"config" json:"config"`
}
HTTPFilters defines the http filter
type InboundRequest ¶ added in v1.1.0
type InboundRequest struct {
RequestType string `json:"requestType" yaml:"requestType"` //http, TO-DO: dubbo
Headers []Params `json:"headers" yaml:"headers"`
QueryStrings []Params `json:"queryStrings" yaml:"queryStrings"`
RequestBody []BodyDefinition `json:"requestBody" yaml:"requestBody"`
}
InboundRequest defines the details of the inbound
type IntegrationRequest ¶ added in v1.1.0
type IntegrationRequest struct {
RequestType string `json:"requestType" yaml:"requestType"` // dubbo, TO-DO: http
DubboBackendConfig `json:"dubboBackendConfig,inline,omitempty" yaml:"dubboBackendConfig,inline,omitempty"`
HTTPBackendConfig `json:"httpBackendConfig,inline,omitempty" yaml:"httpBackendConfig,inline,omitempty"`
MappingParams []MappingParam `json:"mappingParams,omitempty" yaml:"mappingParams,omitempty"`
}
IntegrationRequest defines the backend request format and target
type Listener ¶ added in v1.1.0
type Listener struct {
Name string `yaml:"name" json:"name"`
Address struct {
SocketAddress struct {
Address string `yaml:"address" json:"address"`
Port int `yaml:"port" json:"port"`
} `yaml:"socket-address" json:"socket_address"`
Name string `yaml:"name" json:"name"`
} `yaml:"address" json:"address"`
RouteConfig RouteConfig `yaml:"route_config" json:"route_config"`
HTTPFilters HTTPFilters `yaml:"http_filters" json:"http_filters"`
}
Listener defines the listener config
type MappingParam ¶ added in v1.1.0
type MappingParam struct {
Name string `json:"name,omitempty" yaml:"name"`
MapTo string `json:"mapTo,omitempty" yaml:"mapTo"`
MapType string `json:"mapType,omitempty" yaml:"mapType"`
}
MappingParam defines the mapping rules of headers and queryStrings
type Method ¶ added in v1.1.0
type Method struct {
ID int `json:"id,omitempty" yaml:"id,omitempty"`
ResourcePath string `json:"resourcePath" yaml:"resourcePath"`
Enable bool `json:"enable" yaml:"enable"` // true means the method is up and false means method is down
Timeout time.Duration `json:"timeout" yaml:"timeout"`
Mock bool `json:"mock" yaml:"mock"`
Filters []Filter `json:"filters" yaml:"filters"`
HTTPVerb string `json:"httpVerb" yaml:"httpVerb"`
InboundRequest `json:"inboundRequest" yaml:"inboundRequest"`
IntegrationRequest `json:"integrationRequest" yaml:"integrationRequest"`
}
Method defines the method of the api
type Params ¶ added in v1.1.0
type Params struct {
Name string `json:"name" yaml:"name"`
Type string `json:"type" yaml:"type"`
Required bool `json:"required" yaml:"required"`
}
Params defines the simple parameter definition
type Resource ¶ added in v1.1.0
type Resource struct {
ID int `json:"id,omitempty" yaml:"id,omitempty"`
Type string `json:"type" yaml:"type"` // Restful, Dubbo
Path string `json:"path" yaml:"path"`
Timeout time.Duration `json:"timeout" yaml:"timeout"`
Description string `json:"description" yaml:"description"`
Filters []Filter `json:"filters" yaml:"filters"`
Methods []Method `json:"methods" yaml:"methods"`
Resources []Resource `json:"resources,omitempty" yaml:"resources,omitempty"`
Headers map[string]string `json:"headers,omitempty" yaml:"headers,omitempty"`
}
Resource defines the API path
type RouteConfig ¶ added in v1.1.0
type RouteConfig struct {
Routes []struct {
Match struct {
Prefix string `yaml:"prefix" json:"prefix"`
} `yaml:"match" json:"match"`
Route struct {
Cluster string `yaml:"cluster" json:"cluster"`
ClusterNotFoundResponseCode int `yaml:"cluster_not_found_response_code" json:"cluster_not_found_response_code"`
} `yaml:"route" json:"route"`
} `yaml:"routes" json:"routes"`
}
RouteConfig defines the route config