Documentation ¶
Index ¶
- Constants
- func ConfigActiveFromENV(key string) (active string)
- func RegisterAuthorizationsRetriever(kind string, retriever AuthorizationsRetriever)
- func RegisterPermissionsDefinitionsLoaderRetriever(kind string, retriever PermissionsDefinitionsLoaderRetriever)
- func RegisterServiceDiscoveryRetriever(kind string, retriever ServiceDiscoveryRetriever)
- func UID() (id string)
- type AbstractService
- type AbstractServiceDiscovery
- type AppRuntime
- type Application
- type ApplicationConfig
- type Argument
- type Authorizations
- type AuthorizationsConfig
- type AuthorizationsRetriever
- type Context
- type ContextMeta
- type CorsConfig
- type DiscoveryConfig
- type Empty
- type FnDocument
- type Hook
- type HookUnit
- type HttpClient
- type HttpClients
- type HttpConfig
- type HttpResponse
- type HttpTlsConfig
- type LocaledServiceProxy
- type LogConfig
- type ObjectDocument
- func ArrayObjectDocument(name string, title string, description string, item *ObjectDocument) *ObjectDocument
- func BoolObjectDocument() *ObjectDocument
- func DateObjectDocument() *ObjectDocument
- func DateTimeObjectDocument() *ObjectDocument
- func EmptyObjectDocument() *ObjectDocument
- func Float32ObjectDocument() *ObjectDocument
- func Float64ObjectDocument() *ObjectDocument
- func Int32ObjectDocument() *ObjectDocument
- func Int64ObjectDocument() *ObjectDocument
- func IntObjectDocument() *ObjectDocument
- func JsonRawObjectDocument() *ObjectDocument
- func MapObjectDocument(name string, title string, description string, item *ObjectDocument) *ObjectDocument
- func NewObjectDocument(pkg string, name string, typ string, format string, title string, ...) *ObjectDocument
- func StringObjectDocument() *ObjectDocument
- func StructObjectDocument(pkg string, name string, title string, description string) *ObjectDocument
- func (obj *ObjectDocument) AddEnum(v ...interface{}) *ObjectDocument
- func (obj *ObjectDocument) AddProperty(name string, prop *ObjectDocument) *ObjectDocument
- func (obj *ObjectDocument) AsDeprecated() *ObjectDocument
- func (obj *ObjectDocument) AsRequired(validation string) *ObjectDocument
- func (obj *ObjectDocument) SetDescription(description string) *ObjectDocument
- func (obj *ObjectDocument) SetExample(example interface{}) *ObjectDocument
- func (obj *ObjectDocument) SetFormat(format string) *ObjectDocument
- func (obj *ObjectDocument) SetTitle(title string) *ObjectDocument
- func (obj *ObjectDocument) SetValidation(validation string) *ObjectDocument
- type Option
- func ConfigRetriever(path string, format string, active string, prefix string, splitter byte) Option
- func CustomizeValidate(validate *validator.Validate) Option
- func GOPROCS(min int, max int) Option
- func Hooks(hooks ...Hook) Option
- func SecretKeyFile(path string) Option
- func Version(version string) Option
- type Options
- type Permissions
- type PermissionsConfig
- type PermissionsDefinitions
- type PermissionsDefinitionsLoader
- type PermissionsDefinitionsLoaderRetriever
- type Registration
- type Registrations
- type RegistrationsManager
- func (manager *RegistrationsManager) Append(registration Registration)
- func (manager *RegistrationsManager) CheckRegistration(registration Registration) (ok bool)
- func (manager *RegistrationsManager) Close()
- func (manager *RegistrationsManager) Get(namespace string) (registration *Registration, exists bool)
- func (manager *RegistrationsManager) ListenProblemChan()
- func (manager *RegistrationsManager) ProblemChan() (ch chan<- *Registration)
- func (manager *RegistrationsManager) Registrations() (v []Registration)
- func (manager *RegistrationsManager) Remove(registration Registration)
- type RemotedServiceProxy
- type Result
- type Service
- type ServiceDiscovery
- type ServiceDiscoveryOption
- type ServiceDiscoveryRetriever
- type ServiceDocument
- type ServiceMeta
- type ServiceMetaBuilder
- type ServiceOption
- type ServiceProxy
- type ServicesConfig
- type User
Constants ¶
View Source
const ( B = 1 << (10 * iota) KB MB GB TB PB EB )
Variables ¶
This section is empty.
Functions ¶
func ConfigActiveFromENV ¶ added in v0.1.1
func RegisterAuthorizationsRetriever ¶
func RegisterAuthorizationsRetriever(kind string, retriever AuthorizationsRetriever)
func RegisterPermissionsDefinitionsLoaderRetriever ¶ added in v0.1.1
func RegisterPermissionsDefinitionsLoaderRetriever(kind string, retriever PermissionsDefinitionsLoaderRetriever)
func RegisterServiceDiscoveryRetriever ¶
func RegisterServiceDiscoveryRetriever(kind string, retriever ServiceDiscoveryRetriever)
Types ¶
type AbstractService ¶ added in v0.9.0
type AbstractService struct {
// contains filtered or unexported fields
}
func NewAbstractService ¶ added in v0.9.0
func NewAbstractService() AbstractService
func NewAbstractServiceWithOption ¶ added in v0.9.0
func NewAbstractServiceWithOption(option ServiceOption) AbstractService
func (AbstractService) Build ¶ added in v0.9.0
func (s AbstractService) Build(config configuares.Config) (err error)
func (AbstractService) Meta ¶ added in v0.9.0
func (s AbstractService) Meta() (v ServiceMeta)
type AbstractServiceDiscovery ¶ added in v0.1.1
type AbstractServiceDiscovery struct { Local ServiceDiscovery Clients *HttpClients Manager *RegistrationsManager }
func NewAbstractServiceDiscovery ¶ added in v0.1.1
func NewAbstractServiceDiscovery(clients *HttpClients) AbstractServiceDiscovery
func (*AbstractServiceDiscovery) Close ¶ added in v0.1.1
func (discovery *AbstractServiceDiscovery) Close()
func (*AbstractServiceDiscovery) IsLocal ¶ added in v0.1.1
func (discovery *AbstractServiceDiscovery) IsLocal(namespace string) (ok bool)
func (*AbstractServiceDiscovery) Proxy ¶ added in v0.1.1
func (discovery *AbstractServiceDiscovery) Proxy(ctx Context, namespace string) (proxy ServiceProxy, err errors.CodeError)
type AppRuntime ¶ added in v0.1.1
type AppRuntime interface { ClusterMode() (ok bool) PublicAddress() (address string) Log() (log logs.Logger) Validate(v interface{}) (err errors.CodeError) ServiceProxy(ctx Context, namespace string) (proxy ServiceProxy, err error) ServiceMeta() (meta ServiceMeta) Authorizations() (authorizations Authorizations) Permissions() (permissions Permissions) HttpClient() (client HttpClient) }
type Application ¶
type Application interface { Log() (log logs.Logger) Deploy(service ...Service) (err error) Run(ctx sc.Context) (err error) Sync() SyncWithTimeout(timeout time.Duration) }
func New ¶
func New(options ...Option) (app Application, err error)
type ApplicationConfig ¶
type ApplicationConfig struct { Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Terms string `json:"terms,omitempty"` Contact *appContact `json:"contact,omitempty"` License *appLicense `json:"license,omitempty"` Concurrency int `json:"concurrency,omitempty"` Http HttpConfig `json:"http,omitempty"` Log LogConfig `json:"log,omitempty"` Services ServicesConfig `json:"services,omitempty"` }
type Argument ¶
type Argument interface { json.Marshaler json.Unmarshaler As(v interface{}) (err errors.CodeError) }
func EmptyArgument ¶ added in v0.6.16
func EmptyArgument() (arg Argument)
func NewArgument ¶
type Authorizations ¶
type AuthorizationsConfig ¶
type AuthorizationsConfig struct { Enable bool `json:"enable,omitempty"` Kind string `json:"kind,omitempty"` Config configuares.Raw `json:"config,omitempty"` }
type AuthorizationsRetriever ¶
type AuthorizationsRetriever func(config configuares.Raw) (authorizations Authorizations, err error)
type Context ¶
type Context interface { sc.Context InternalRequested() (ok bool) RequestId() (id string) User() (user User) Meta() (meta ContextMeta) Timeout() (has bool) App() (app AppRuntime) }
func WithNamespace ¶
func WithServiceMeta ¶ added in v0.9.0
func WithServiceMeta(ctx Context, meta ServiceMeta) Context
type ContextMeta ¶
type ContextMeta interface { Exists(key string) (has bool) Put(key string, value interface{}) Get(key string, value interface{}) (err error) Remove(key string) GetString(key string) (value string, has bool) GetInt(key string) (value int, has bool) GetInt32(key string) (value int32, has bool) GetInt64(key string) (value int64, has bool) GetFloat32(key string) (value float32, has bool) GetFloat64(key string) (value float64, has bool) GetBool(key string) (value bool, has bool) GetTime(key string) (value time.Time, has bool) GetDuration(key string) (value time.Duration, has bool) SetExactProxyServiceAddress(namespace string, address string) GetExactProxyServiceAddress(namespace string) (address string, has bool) DelExactProxyServiceAddress(namespace string) Encode() (value []byte) }
type CorsConfig ¶
type CorsConfig struct { Enable bool `json:"enable,omitempty"` AllowedOrigins []string `json:"allowedOrigins,omitempty"` AllowedMethods []string `json:"allowedMethods,omitempty"` AllowedHeaders []string `json:"allowedHeaders,omitempty"` ExposedHeaders []string `json:"exposedHeaders,omitempty"` AllowCredentials bool `json:"allowCredentials,omitempty"` MaxAge int `json:"maxAge,omitempty"` }
type DiscoveryConfig ¶
type DiscoveryConfig struct { Enable bool `json:"enable,omitempty"` Kind string `json:"kind,omitempty"` Config configuares.Raw `json:"config,omitempty"` }
type FnDocument ¶ added in v0.8.4
type FnDocument struct { Name string `json:"name,omitempty"` Title string `json:"title,omitempty"` Description string `json:"description,omitempty"` HasAuthorization bool `json:"hasAuthorization,omitempty"` Argument *ObjectDocument `json:"argument,omitempty"` Result *ObjectDocument `json:"result,omitempty"` Deprecated bool `json:"deprecated,omitempty"` }
func NewFnDocument ¶ added in v0.8.4
func (*FnDocument) SetArgument ¶ added in v0.8.5
func (doc *FnDocument) SetArgument(v *ObjectDocument)
func (*FnDocument) SetResult ¶ added in v0.8.5
func (doc *FnDocument) SetResult(v *ObjectDocument)
type Hook ¶
type Hook interface { Build(config configuares.Config) (err error) Handle(unit HookUnit) Close() }
type HttpClient ¶ added in v0.1.1
type HttpClient interface { Get(url string, head http.Header, timeout time.Duration) (response *HttpResponse, err error) Post(url string, head http.Header, body []byte, timeout time.Duration) (response *HttpResponse, err error) Put(url string, head http.Header, body []byte, timeout time.Duration) (response *HttpResponse, err error) Delete(url string, head http.Header, timeout time.Duration) (response *HttpResponse, err error) }
type HttpClients ¶ added in v0.1.1
type HttpClients struct {
// contains filtered or unexported fields
}
func NewHttpClients ¶ added in v0.1.1
func NewHttpClients(poolSize int) (hc *HttpClients)
func (*HttpClients) Close ¶ added in v0.1.1
func (hc *HttpClients) Close()
type HttpConfig ¶
type HttpConfig struct { Host string `json:"host,omitempty"` Port int `json:"port,omitempty"` PublicHost string `json:"publicHost,omitempty"` PublicPort int `json:"publicPort,omitempty"` MaxConnectionsPerIP int `json:"maxConnectionsPerIp,omitempty"` MaxRequestsPerConnection int `json:"maxRequestsPerConnection,omitempty"` KeepAlive bool `json:"keepAlive,omitempty"` KeepalivePeriodSecond int `json:"keepalivePeriodSecond,omitempty"` RequestTimeoutSeconds int `json:"requestTimeoutSeconds,omitempty"` ReadBufferSize string `json:"readBufferSize"` WriteBufferSize string `json:"writeBufferSize"` Cors CorsConfig `json:"cors"` TLS HttpTlsConfig `json:"tls,omitempty"` }
type HttpResponse ¶ added in v0.1.1
type HttpTlsConfig ¶ added in v0.8.4
type LocaledServiceProxy ¶ added in v0.1.1
type LocaledServiceProxy struct {
// contains filtered or unexported fields
}
func NewLocaledServiceProxy ¶ added in v0.1.1
func NewLocaledServiceProxy(service Service) *LocaledServiceProxy
type ObjectDocument ¶ added in v0.8.4
type ObjectDocument struct { Package string `json:"package,omitempty"` Name string `json:"name,omitempty"` Title string `json:"title,omitempty"` Description string `json:"description,omitempty"` Type string `json:"type,omitempty"` Format string `json:"format,omitempty"` Enum []interface{} `json:"enum,omitempty"` Required bool `json:"required,omitempty"` Validation string `json:"validation,omitempty"` Properties map[string]*ObjectDocument `json:"properties,omitempty"` Additional bool `json:"additional,omitempty"` Deprecated bool `json:"deprecated,omitempty"` Example interface{} `json:"example,omitempty"` }
func ArrayObjectDocument ¶ added in v0.8.4
func ArrayObjectDocument(name string, title string, description string, item *ObjectDocument) *ObjectDocument
func BoolObjectDocument ¶ added in v0.8.4
func BoolObjectDocument() *ObjectDocument
func DateObjectDocument ¶ added in v0.8.4
func DateObjectDocument() *ObjectDocument
func DateTimeObjectDocument ¶ added in v0.8.4
func DateTimeObjectDocument() *ObjectDocument
func EmptyObjectDocument ¶ added in v0.8.4
func EmptyObjectDocument() *ObjectDocument
func Float32ObjectDocument ¶ added in v0.8.4
func Float32ObjectDocument() *ObjectDocument
func Float64ObjectDocument ¶ added in v0.8.4
func Float64ObjectDocument() *ObjectDocument
func Int32ObjectDocument ¶ added in v0.8.5
func Int32ObjectDocument() *ObjectDocument
func Int64ObjectDocument ¶ added in v0.8.4
func Int64ObjectDocument() *ObjectDocument
func IntObjectDocument ¶ added in v0.8.4
func IntObjectDocument() *ObjectDocument
func JsonRawObjectDocument ¶ added in v0.8.5
func JsonRawObjectDocument() *ObjectDocument
func MapObjectDocument ¶ added in v0.8.4
func MapObjectDocument(name string, title string, description string, item *ObjectDocument) *ObjectDocument
func NewObjectDocument ¶ added in v0.8.5
func StringObjectDocument ¶ added in v0.8.4
func StringObjectDocument() *ObjectDocument
func StructObjectDocument ¶ added in v0.8.6
func StructObjectDocument(pkg string, name string, title string, description string) *ObjectDocument
func (*ObjectDocument) AddEnum ¶ added in v0.8.5
func (obj *ObjectDocument) AddEnum(v ...interface{}) *ObjectDocument
func (*ObjectDocument) AddProperty ¶ added in v0.8.4
func (obj *ObjectDocument) AddProperty(name string, prop *ObjectDocument) *ObjectDocument
func (*ObjectDocument) AsDeprecated ¶ added in v0.8.5
func (obj *ObjectDocument) AsDeprecated() *ObjectDocument
func (*ObjectDocument) AsRequired ¶ added in v0.8.5
func (obj *ObjectDocument) AsRequired(validation string) *ObjectDocument
func (*ObjectDocument) SetDescription ¶ added in v0.8.6
func (obj *ObjectDocument) SetDescription(description string) *ObjectDocument
func (*ObjectDocument) SetExample ¶ added in v0.8.6
func (obj *ObjectDocument) SetExample(example interface{}) *ObjectDocument
func (*ObjectDocument) SetFormat ¶ added in v0.8.6
func (obj *ObjectDocument) SetFormat(format string) *ObjectDocument
func (*ObjectDocument) SetTitle ¶ added in v0.8.6
func (obj *ObjectDocument) SetTitle(title string) *ObjectDocument
func (*ObjectDocument) SetValidation ¶ added in v0.8.6
func (obj *ObjectDocument) SetValidation(validation string) *ObjectDocument
type Option ¶
func ConfigRetriever ¶
func CustomizeValidate ¶
func CustomizeValidate(validate *validator.Validate) Option
func SecretKeyFile ¶
type Options ¶
type Options struct { ConfigRetrieverOption configuares.RetrieverOption Validate *validator.Validate Hooks []Hook Version string SecretKey []byte MinPROCS int MaxPROCS int }
type Permissions ¶
type Permissions interface { // Validate 验证当前 context 中 user 对 fn 的权限 Validate(ctx Context, namespace string, fn string) (err errors.CodeError) // SaveUserRoles 将角色保存到 当前 context 的 user attributes 中 SaveUserRoles(ctx Context, roles ...string) (err errors.CodeError) }
Permissions 基于RBAC的权限控制器 角色:角色树,控制器不存储用户的角色。 资源:fn 控制:是否可以使用(不可以使用优先于可以使用)
type PermissionsConfig ¶
type PermissionsConfig struct { Enable bool `json:"enable,omitempty"` Loader string `json:"loader,omitempty"` Config configuares.Raw `json:"config,omitempty"` }
type PermissionsDefinitions ¶ added in v0.1.1
type PermissionsDefinitions struct {
// contains filtered or unexported fields
}
func (*PermissionsDefinitions) Accessible ¶ added in v0.1.1
func (d *PermissionsDefinitions) Accessible(namespace string, fn string, roles []string) (accessible bool)
type PermissionsDefinitionsLoader ¶ added in v0.1.1
type PermissionsDefinitionsLoader interface {
Load() (definitions *PermissionsDefinitions, err errors.CodeError)
}
PermissionsDefinitionsLoader 存储权限设定的加载器
type PermissionsDefinitionsLoaderRetriever ¶ added in v0.1.1
type PermissionsDefinitionsLoaderRetriever func(config configuares.Raw) (loader PermissionsDefinitionsLoader, err error)
type Registration ¶ added in v0.1.1
type Registration struct { Id string `json:"id"` Namespace string `json:"namespace,omitempty"` Address string `json:"address"` Reversion int64 `json:"-"` }
func (Registration) Key ¶ added in v0.1.1
func (r Registration) Key() (key string)
type Registrations ¶ added in v0.1.1
type Registrations struct {
// contains filtered or unexported fields
}
func NewRegistrations ¶ added in v0.1.1
func NewRegistrations() (registrations *Registrations)
func (*Registrations) Append ¶ added in v0.1.1
func (r *Registrations) Append(v Registration)
func (*Registrations) Next ¶ added in v0.1.1
func (r *Registrations) Next() (v *Registration, has bool)
func (*Registrations) Remove ¶ added in v0.1.1
func (r *Registrations) Remove(v Registration)
func (*Registrations) Size ¶ added in v0.1.1
func (r *Registrations) Size() (size int)
type RegistrationsManager ¶ added in v0.1.1
type RegistrationsManager struct {
// contains filtered or unexported fields
}
func (*RegistrationsManager) Append ¶ added in v0.1.1
func (manager *RegistrationsManager) Append(registration Registration)
func (*RegistrationsManager) CheckRegistration ¶ added in v0.1.1
func (manager *RegistrationsManager) CheckRegistration(registration Registration) (ok bool)
func (*RegistrationsManager) Close ¶ added in v0.1.1
func (manager *RegistrationsManager) Close()
func (*RegistrationsManager) Get ¶ added in v0.1.1
func (manager *RegistrationsManager) Get(namespace string) (registration *Registration, exists bool)
func (*RegistrationsManager) ListenProblemChan ¶ added in v0.1.1
func (manager *RegistrationsManager) ListenProblemChan()
func (*RegistrationsManager) ProblemChan ¶ added in v0.1.1
func (manager *RegistrationsManager) ProblemChan() (ch chan<- *Registration)
func (*RegistrationsManager) Registrations ¶ added in v0.1.1
func (manager *RegistrationsManager) Registrations() (v []Registration)
func (*RegistrationsManager) Remove ¶ added in v0.1.1
func (manager *RegistrationsManager) Remove(registration Registration)
type RemotedServiceProxy ¶
type RemotedServiceProxy struct {
// contains filtered or unexported fields
}
func NewRemotedServiceProxy ¶ added in v0.1.1
func NewRemotedServiceProxy(clients *HttpClients, registration *Registration, problemCh chan<- *Registration) (proxy *RemotedServiceProxy)
type Result ¶
type Result interface { Succeed(v interface{}) Failed(err errors.CodeError) Get(ctx sc.Context, v interface{}) (err errors.CodeError) }
func AsyncResult ¶
func AsyncResult() Result
func SyncResult ¶
func SyncResult() Result
type Service ¶
type Service interface { Namespace() (namespace string) Internal() (internal bool) Build(config configuares.Config) (err error) Document() (doc *ServiceDocument) Handle(context Context, fn string, argument Argument) (result interface{}, err errors.CodeError) Shutdown() (err error) }
Service 管理 Fn 的服务
type ServiceDiscovery ¶
type ServiceDiscoveryOption ¶
type ServiceDiscoveryOption struct { Address string HttpClients *HttpClients Config configuares.Raw }
type ServiceDiscoveryRetriever ¶
type ServiceDiscoveryRetriever func(option ServiceDiscoveryOption) (discovery ServiceDiscovery, err error)
type ServiceDocument ¶ added in v0.6.26
type ServiceDocument struct { // Namespace // as tag Namespace string `json:"namespace,omitempty"` // Description // as description of tag, support markdown Description string `json:"description,omitempty"` // Fns // key: fn Fns map[string]*FnDocument `json:"fns,omitempty"` }
func NewServiceDocument ¶ added in v0.8.4
func NewServiceDocument(namespace string, description string) *ServiceDocument
func (*ServiceDocument) AddFn ¶ added in v0.8.4
func (doc *ServiceDocument) AddFn(fn *FnDocument)
type ServiceMeta ¶ added in v0.9.0
type ServiceMeta map[string]interface{}
func NewServiceMeta ¶ added in v0.9.0
func NewServiceMeta() ServiceMeta
func (ServiceMeta) Get ¶ added in v0.9.0
func (meta ServiceMeta) Get(key string) (v interface{}, has bool)
func (ServiceMeta) Set ¶ added in v0.9.0
func (meta ServiceMeta) Set(key string, value interface{})
type ServiceMetaBuilder ¶ added in v0.9.0
type ServiceMetaBuilder func(config configuares.Config) (meta ServiceMeta, err error)
type ServiceOption ¶ added in v0.9.0
type ServiceOption struct {
MetaBuilder ServiceMetaBuilder
}
type ServiceProxy ¶
type ServicesConfig ¶
type ServicesConfig struct { HandleTimeoutSecond int `json:"handleTimeoutSecond,omitempty"` MaxIdleTimeSecond int `json:"maxIdleTimeSecond,omitempty"` ReduceMemoryUsage bool `json:"reduceMemoryUsage,omitempty"` Discovery DiscoveryConfig `json:"discovery,omitempty"` Authorization AuthorizationsConfig `json:"authorization,omitempty"` Permission PermissionsConfig `json:"permission,omitempty"` HttpClientPoolSize int `json:"httpClientPoolSize,omitempty"` }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.