Documentation ¶
Index ¶
- Constants
- Variables
- func Global(key string, defaultValue string, description string)
- type Config
- func (c *Config) All(ctx context.Context) []*ServiceConfig
- func (c *Config) GenPageConfig(ctx context.Context) *react.PageConfig
- func (c *Config) Get(ctx context.Context, key string) *ServiceConfig
- func (c *Config) GetBoolDefaultValue(key string) bool
- func (c *Config) GetBoolValue(ctx context.Context, key string) bool
- func (c *Config) GetDefaultValue(key string) string
- func (c *Config) GetFacebookConfig(ctx context.Context) *OAuth2Config
- func (c *Config) GetFloatDefaultValue(key string) float64
- func (c *Config) GetFloatValue(ctx context.Context, key string) float64
- func (c *Config) GetIntDefaultValue(key string) int
- func (c *Config) GetIntValue(ctx context.Context, key string) int
- func (c *Config) GetMessengerVerificationToken(ctx context.Context) string
- func (c *Config) GetValue(ctx context.Context, key string) string
- func (c *Config) LoadFromJSON(ctx context.Context, path string)
- func (c *Config) NewHTTPClient(ctx context.Context) *http.Client
- func (c *Config) NewMessengerSender(ctx context.Context) (*messenger.Sender, error)
- func (c *Config) Register(key string, defaultValue string, description string)
- func (c *Config) Set(ctx context.Context, cfg *ServiceConfig)
- func (c *Config) SetValue(ctx context.Context, key string, value string)
- type OAuth2Config
- type ServiceConfig
- type ServiceConfigKind
- func (k *ServiceConfigKind) Delete(ctx context.Context, key interface{}) (*datastore.Key, error)
- func (k *ServiceConfigKind) DeleteMatched(ctx context.Context, q *ServiceConfigQuery) (int, error)
- func (k *ServiceConfigKind) DeleteMulti(ctx context.Context, keys interface{}) ([]*datastore.Key, error)
- func (k *ServiceConfigKind) EnforceNamespace(ns string, b bool) *ServiceConfigKind
- func (k *ServiceConfigKind) Get(ctx context.Context, key interface{}) (*datastore.Key, *ServiceConfig, error)
- func (k *ServiceConfigKind) GetMulti(ctx context.Context, keys interface{}) ([]*datastore.Key, []*ServiceConfig, error)
- func (k *ServiceConfigKind) MustDelete(ctx context.Context, key interface{}) *datastore.Key
- func (k *ServiceConfigKind) MustDeleteMulti(ctx context.Context, keys interface{}) []*datastore.Key
- func (k *ServiceConfigKind) MustGet(ctx context.Context, key interface{}) *ServiceConfig
- func (k *ServiceConfigKind) MustGetMulti(ctx context.Context, keys interface{}) []*ServiceConfig
- func (k *ServiceConfigKind) MustPut(ctx context.Context, ent *ServiceConfig) *datastore.Key
- func (k *ServiceConfigKind) MustPutMulti(ctx context.Context, ents []*ServiceConfig) []*datastore.Key
- func (k *ServiceConfigKind) MustReplace(ctx context.Context, ent *ServiceConfig, replacer ServiceConfigKindReplacer) (*datastore.Key, *ServiceConfig)
- func (k *ServiceConfigKind) MustReplaceMulti(ctx context.Context, ents []*ServiceConfig, replacer ServiceConfigKindReplacer) ([]*datastore.Key, []*ServiceConfig)
- func (k *ServiceConfigKind) Put(ctx context.Context, ent *ServiceConfig) (*datastore.Key, error)
- func (k *ServiceConfigKind) PutMulti(ctx context.Context, ents []*ServiceConfig) ([]*datastore.Key, error)
- func (k *ServiceConfigKind) Replace(ctx context.Context, ent *ServiceConfig, replacer ServiceConfigKindReplacer) (*datastore.Key, *ServiceConfig, error)
- func (k *ServiceConfigKind) ReplaceMulti(ctx context.Context, ents []*ServiceConfig, replacer ServiceConfigKindReplacer) ([]*datastore.Key, []*ServiceConfig, error)
- func (k *ServiceConfigKind) UseDefaultIfNil(b bool) *ServiceConfigKind
- type ServiceConfigKindReplacer
- type ServiceConfigKindReplacerFunc
- type ServiceConfigPagination
- type ServiceConfigQuery
- func (q *ServiceConfigQuery) Ancestor(a lazy.Value) *ServiceConfigQuery
- func (q *ServiceConfigQuery) Asc(name string) *ServiceConfigQuery
- func (q *ServiceConfigQuery) Count(ctx context.Context) (int, error)
- func (q *ServiceConfigQuery) Desc(name string) *ServiceConfigQuery
- func (q *ServiceConfigQuery) End(value lazy.Value) *ServiceConfigQuery
- func (q *ServiceConfigQuery) Eq(name string, value lazy.Value) *ServiceConfigQuery
- func (q *ServiceConfigQuery) Ge(name string, value lazy.Value) *ServiceConfigQuery
- func (q *ServiceConfigQuery) GetAll(ctx context.Context) ([]*datastore.Key, []*ServiceConfig, error)
- func (q *ServiceConfigQuery) GetAllValues(ctx context.Context) ([]*ServiceConfig, error)
- func (q *ServiceConfigQuery) Gt(name string, value lazy.Value) *ServiceConfigQuery
- func (q *ServiceConfigQuery) Le(name string, value lazy.Value) *ServiceConfigQuery
- func (q *ServiceConfigQuery) Limit(n lazy.Value) *ServiceConfigQuery
- func (q *ServiceConfigQuery) Lt(name string, value lazy.Value) *ServiceConfigQuery
- func (q *ServiceConfigQuery) MustCount(ctx context.Context) int
- func (q *ServiceConfigQuery) MustGetAll(ctx context.Context) ([]*datastore.Key, []*ServiceConfig)
- func (q *ServiceConfigQuery) MustGetAllValues(ctx context.Context) []*ServiceConfig
- func (q *ServiceConfigQuery) MustRun(ctx context.Context) *ServiceConfigPagination
- func (q *ServiceConfigQuery) Ne(name string, value lazy.Value) *ServiceConfigQuery
- func (q *ServiceConfigQuery) Run(ctx context.Context) (*ServiceConfigPagination, error)
- func (q *ServiceConfigQuery) Start(value lazy.Value) *ServiceConfigQuery
- func (q *ServiceConfigQuery) ViaKeys(k *ServiceConfigKind) *ServiceConfigQuery
Constants ¶
const HTTPClientLoggerKey = "gae.service.config.http"
HTTPClientLoggerKey is a xlog key for this package
const ServiceConfigKindLoggerKey = "ent.service_config"
ServiceConfigKindLoggerKey is a logger key name for the ent
const ServiceConfigQueryLoggerKey = "ent.query.service_config"
ServiceConfigQueryLoggerKey is a logger key name for the ent
Variables ¶
var DefaultServiceConfigKind = &ServiceConfigKind{}
DefaultServiceConfigKind is a default value of *ServiceConfigKind
Functions ¶
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config is a struct to access configurations represented by *ServiceConfig
func (*Config) All ¶
func (c *Config) All(ctx context.Context) []*ServiceConfig
All returns all *ServiceConfig in app.
func (*Config) GenPageConfig ¶
func (c *Config) GenPageConfig(ctx context.Context) *react.PageConfig
GenPageConfig returns *react.PageConfig from configuration datastore.
func (*Config) Get ¶
func (c *Config) Get(ctx context.Context, key string) *ServiceConfig
Get gets the *ServiceConfig
func (*Config) GetBoolDefaultValue ¶
GetBoolDefaultValue returns the default value by `key` as bool
func (*Config) GetBoolValue ¶
GetBoolValue is like GetValue and return the value as bool. If invalid int value is set on `key` this will return a default value of `key`.
func (*Config) GetDefaultValue ¶
GetDefaultValue returns the default value by `key`
func (*Config) GetFacebookConfig ¶
func (c *Config) GetFacebookConfig(ctx context.Context) *OAuth2Config
GetFacebookConfig returns OAuth2 config for facebook.
func (*Config) GetFloatDefaultValue ¶
GetFloatDefaultValue returns the default value by `key` as float64
func (*Config) GetFloatValue ¶
GetFloatValue is like GetValue and return the value as float64. If invalid int value is set on `key` this will return a default value of `key`.
func (*Config) GetIntDefaultValue ¶
GetIntDefaultValue returns the default value by `key` as int
func (*Config) GetIntValue ¶
GetIntValue is like GetValue and return the value as int. If invalid int value is set on `key` this will return a default value of `key`.
func (*Config) GetMessengerVerificationToken ¶
GetMessengerVerificationToken returns messenger verification token string
func (*Config) LoadFromJSON ¶
LoadFromJSON loads config values from a given file path
func (*Config) NewHTTPClient ¶
NewHTTPClient is an http client available in this context
func (*Config) NewMessengerSender ¶
NewMessengerSender returns a new *messenger.Sender from server configuration
type OAuth2Config ¶
OAuth2Config is a configuration object for oauth2 clients
type ServiceConfig ¶
type ServiceConfig struct { Key string `json:"key" ent:"id"` Value string `json:"value" ent:"form" datastore:",noindex"` UpdatedAt time.Time `json:"updated_at" ent:"timestamp" datastore:",noindex"` Description string `json:"description" datastore:"-"` DefaultValue string `json:"default_value" datastore:"-"` GlobalValue string `json:"global_value" datastore:"-"` // contains filtered or unexported fields }
ServiceConfig is a configuration object for a service
func NewServiceConfig ¶
func NewServiceConfig() *ServiceConfig
NewServiceConfig returns a new *ServiceConfig with default field values.
func (*ServiceConfig) UpdateByForm ¶
func (s *ServiceConfig) UpdateByForm(form *keyvalue.GetProxy)
UpdateByForm updates the fields by form values. All values should be validated before calling this function.
type ServiceConfigKind ¶
type ServiceConfigKind struct {
// contains filtered or unexported fields
}
func (*ServiceConfigKind) DeleteMatched ¶
func (k *ServiceConfigKind) DeleteMatched(ctx context.Context, q *ServiceConfigQuery) (int, error)
DeleteMatched deletes the all ents that match with the query. This func modify Limit/StartKey condition in the query so that you should restore it if you want to reuse the query.
func (*ServiceConfigKind) DeleteMulti ¶
func (k *ServiceConfigKind) DeleteMulti(ctx context.Context, keys interface{}) ([]*datastore.Key, error)
DeleteMulti do Delete with multiple keys
func (*ServiceConfigKind) EnforceNamespace ¶
func (k *ServiceConfigKind) EnforceNamespace(ns string, b bool) *ServiceConfigKind
EnforceNamespace enforces namespace for Get/Put/Delete or not.
func (*ServiceConfigKind) Get ¶
func (k *ServiceConfigKind) Get(ctx context.Context, key interface{}) (*datastore.Key, *ServiceConfig, error)
Get gets the kind entity from datastore
func (*ServiceConfigKind) GetMulti ¶
func (k *ServiceConfigKind) GetMulti(ctx context.Context, keys interface{}) ([]*datastore.Key, []*ServiceConfig, error)
GetMulti do Get with multiple keys. keys must be []string, []*datastore.Key, or []interface{}
func (*ServiceConfigKind) MustDelete ¶
func (k *ServiceConfigKind) MustDelete(ctx context.Context, key interface{}) *datastore.Key
MustDelete is like Delete but panic if an error occurs
func (*ServiceConfigKind) MustDeleteMulti ¶
func (k *ServiceConfigKind) MustDeleteMulti(ctx context.Context, keys interface{}) []*datastore.Key
MustDeleteMulti is like DeleteMulti but panic if an error occurs
func (*ServiceConfigKind) MustGet ¶
func (k *ServiceConfigKind) MustGet(ctx context.Context, key interface{}) *ServiceConfig
MustGet is like Get but returns only values and panic if error happens.
func (*ServiceConfigKind) MustGetMulti ¶
func (k *ServiceConfigKind) MustGetMulti(ctx context.Context, keys interface{}) []*ServiceConfig
MustGetMulti is like GetMulti but returns only values and panic if error happens.
func (*ServiceConfigKind) MustPut ¶
func (k *ServiceConfigKind) MustPut(ctx context.Context, ent *ServiceConfig) *datastore.Key
MustPut is like Put and panic if an error occurrs.
func (*ServiceConfigKind) MustPutMulti ¶
func (k *ServiceConfigKind) MustPutMulti(ctx context.Context, ents []*ServiceConfig) []*datastore.Key
MustPutMulti is like PutMulti but panic if an error occurs
func (*ServiceConfigKind) MustReplace ¶
func (k *ServiceConfigKind) MustReplace(ctx context.Context, ent *ServiceConfig, replacer ServiceConfigKindReplacer) (*datastore.Key, *ServiceConfig)
func (*ServiceConfigKind) MustReplaceMulti ¶
func (k *ServiceConfigKind) MustReplaceMulti(ctx context.Context, ents []*ServiceConfig, replacer ServiceConfigKindReplacer) ([]*datastore.Key, []*ServiceConfig)
func (*ServiceConfigKind) Put ¶
func (k *ServiceConfigKind) Put(ctx context.Context, ent *ServiceConfig) (*datastore.Key, error)
Put puts the entity to datastore.
func (*ServiceConfigKind) PutMulti ¶
func (k *ServiceConfigKind) PutMulti(ctx context.Context, ents []*ServiceConfig) ([]*datastore.Key, error)
PutMulti do Put with multiple keys
func (*ServiceConfigKind) Replace ¶
func (k *ServiceConfigKind) Replace(ctx context.Context, ent *ServiceConfig, replacer ServiceConfigKindReplacer) (*datastore.Key, *ServiceConfig, error)
func (*ServiceConfigKind) ReplaceMulti ¶
func (k *ServiceConfigKind) ReplaceMulti(ctx context.Context, ents []*ServiceConfig, replacer ServiceConfigKindReplacer) ([]*datastore.Key, []*ServiceConfig, error)
func (*ServiceConfigKind) UseDefaultIfNil ¶
func (k *ServiceConfigKind) UseDefaultIfNil(b bool) *ServiceConfigKind
type ServiceConfigKindReplacer ¶
type ServiceConfigKindReplacer interface {
Replace(*ServiceConfig, *ServiceConfig) *ServiceConfig
}
type ServiceConfigKindReplacerFunc ¶
type ServiceConfigKindReplacerFunc func(*ServiceConfig, *ServiceConfig) *ServiceConfig
func (ServiceConfigKindReplacerFunc) Replace ¶
func (f ServiceConfigKindReplacerFunc) Replace(ent1 *ServiceConfig, ent2 *ServiceConfig) *ServiceConfig
type ServiceConfigPagination ¶
type ServiceConfigQuery ¶
type ServiceConfigQuery struct {
// contains filtered or unexported fields
}
ServiceConfigQuery helps to build and execute a query
func NewServiceConfigQuery ¶
func NewServiceConfigQuery() *ServiceConfigQuery
func (*ServiceConfigQuery) Ancestor ¶
func (q *ServiceConfigQuery) Ancestor(a lazy.Value) *ServiceConfigQuery
Ancestor sets the ancestor filter
func (*ServiceConfigQuery) Asc ¶
func (q *ServiceConfigQuery) Asc(name string) *ServiceConfigQuery
Asc specifies ascending order on the given filed.
func (*ServiceConfigQuery) Count ¶
func (q *ServiceConfigQuery) Count(ctx context.Context) (int, error)
Count returns the count of entities
func (*ServiceConfigQuery) Desc ¶
func (q *ServiceConfigQuery) Desc(name string) *ServiceConfigQuery
Desc specifies descending order on the given filed.
func (*ServiceConfigQuery) End ¶
func (q *ServiceConfigQuery) End(value lazy.Value) *ServiceConfigQuery
Limit specifies the numbe of limit returend by this query.
func (*ServiceConfigQuery) Eq ¶
func (q *ServiceConfigQuery) Eq(name string, value lazy.Value) *ServiceConfigQuery
Eq sets the "=" filter on the name field.
func (*ServiceConfigQuery) Ge ¶
func (q *ServiceConfigQuery) Ge(name string, value lazy.Value) *ServiceConfigQuery
Ge sets the ">=" filter on the "name" field.
func (*ServiceConfigQuery) GetAll ¶
func (q *ServiceConfigQuery) GetAll(ctx context.Context) ([]*datastore.Key, []*ServiceConfig, error)
GetAll returns all key and value of the query.
func (*ServiceConfigQuery) GetAllValues ¶
func (q *ServiceConfigQuery) GetAllValues(ctx context.Context) ([]*ServiceConfig, error)
GetAllValues is like GetAll but returns only values
func (*ServiceConfigQuery) Gt ¶
func (q *ServiceConfigQuery) Gt(name string, value lazy.Value) *ServiceConfigQuery
Gt sets the ">" filter on the "name" field.
func (*ServiceConfigQuery) Le ¶
func (q *ServiceConfigQuery) Le(name string, value lazy.Value) *ServiceConfigQuery
Le sets the "<=" filter on the "name" field.
func (*ServiceConfigQuery) Limit ¶
func (q *ServiceConfigQuery) Limit(n lazy.Value) *ServiceConfigQuery
Limit specifies the numbe of limit returend by this query.
func (*ServiceConfigQuery) Lt ¶
func (q *ServiceConfigQuery) Lt(name string, value lazy.Value) *ServiceConfigQuery
Lt sets the "<" filter on the "name" field.
func (*ServiceConfigQuery) MustCount ¶
func (q *ServiceConfigQuery) MustCount(ctx context.Context) int
MustCount returns the count of entities
func (*ServiceConfigQuery) MustGetAll ¶
func (q *ServiceConfigQuery) MustGetAll(ctx context.Context) ([]*datastore.Key, []*ServiceConfig)
MustGetAll is like GetAll but panic if an error occurrs.
func (*ServiceConfigQuery) MustGetAllValues ¶
func (q *ServiceConfigQuery) MustGetAllValues(ctx context.Context) []*ServiceConfig
MustGetAllValues is like GetAllValues but panic if an error occurrs
func (*ServiceConfigQuery) MustRun ¶
func (q *ServiceConfigQuery) MustRun(ctx context.Context) *ServiceConfigPagination
MustRun is like Run but panic if an error occurrs
func (*ServiceConfigQuery) Ne ¶
func (q *ServiceConfigQuery) Ne(name string, value lazy.Value) *ServiceConfigQuery
Ne sets the "!=" filter on the "name" field.
func (*ServiceConfigQuery) Run ¶
func (q *ServiceConfigQuery) Run(ctx context.Context) (*ServiceConfigPagination, error)
Run returns the a result as *ServiceConfigPagination object
func (*ServiceConfigQuery) Start ¶
func (q *ServiceConfigQuery) Start(value lazy.Value) *ServiceConfigQuery
Limit specifies the numbe of limit returend by this query.
func (*ServiceConfigQuery) ViaKeys ¶
func (q *ServiceConfigQuery) ViaKeys(k *ServiceConfigKind) *ServiceConfigQuery
ViaKeys optimize to execute keys-only query then call k.GetMulti() to fetch values. This would reduce the datastore query and maximize the memcache usage if the query called many times in a short time window.