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 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 Hook
- type HookUnit
- type HttpClient
- type HttpClients
- type HttpConfig
- type HttpResponse
- type LocaledServiceProxy
- type LogConfig
- 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 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 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) 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"` 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 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 RequestId() (id string) User() (user User) Meta() (meta ContextMeta) Timeout() (has bool) App() (app AppRuntime) }
func WithNamespace ¶
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) Decode(value []byte) (ok bool) }
type CorsConfig ¶
type CorsConfig struct { Enabled bool `json:"enabled,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 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"` Cors CorsConfig `json:"cors,omitempty"` }
type HttpResponse ¶ added in v0.1.1
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 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) Description() (description []byte) Handle(context Context, fn string, argument Argument) (result interface{}, err errors.CodeError) Close() (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 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"` // contains filtered or unexported fields }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.