Documentation ¶
Index ¶
- Constants
- Variables
- func AsMap(obj interface{}) map[string]interface{}
- func BoolBytes(value bool) []byte
- func EnableResponseLogging()
- func EndpointLockValue(addr string) string
- func FillFromMap(values map[string]string, obj interface{}) error
- func FloatBytes(value float64) []byte
- func Http_application_error(w http.ResponseWriter, r *http.Request, err error)
- func Http_check_response(resp *http.Response, err error, the_url string) ([]byte, error)
- func Http_get_json(the_url string, result interface{}) error
- func Http_get_json_map(the_url string, requiredKeys ...string) (map[string]interface{}, error)
- func Http_json_map_response(_response *http.Response, err error, url string, requiredKeys ...string) (map[string]interface{}, error)
- func Http_json_response(resp *http.Response, err error, url string, result interface{}) error
- func Http_parse_json_response(resp *http.Response, err error, url string) (interface{}, error)
- func Http_post_string(the_url string, data url.Values) (string, error)
- func Http_respond(w http.ResponseWriter, r *http.Request, data []byte, code int)
- func Http_respond_error(w http.ResponseWriter, r *http.Request, err string, code int)
- func Http_respond_json(w http.ResponseWriter, r *http.Request, value interface{})
- func Http_simple_post(the_url string) error
- func MakeHash(data ...interface{}) string
- func MakeHttpResponse(req *http.Request, code int, bodyContent string) *http.Response
- func MatchFormKeys(keys ...string) func(r *http.Request, rm *mux.RouteMatch) bool
- func ParseBalanceEndpointsFlags()
- func ParseLoadBalanceConfig()
- func RegisterLockScripts(client Redis) error
- func UintBytes(value uint64) []byte
- type HttpError
- type HttpStatusError
- type LogLevel
- type Logger
- func (logger *Logger) Enable(level LogLevel)
- func (logger *Logger) Enabled() bool
- func (logger *Logger) LevelEnabled(level LogLevel) bool
- func (logger *Logger) LogLevelf(level LogLevel, fmt string, v ...interface{})
- func (logger *Logger) Logf(fmt string, v ...interface{})
- func (logger *Logger) Tracef(fmt string, v ...interface{})
- func (logger *Logger) Warnf(fmt string, v ...interface{})
- type Redis
- type RedisLock
- func (lock *RedisLock) Extend() error
- func (lock *RedisLock) ExtendIn(redis Redis) error
- func (lock *RedisLock) ExtendTransaction(transaction func(redis Redis) error) error
- func (lock *RedisLock) Lock() error
- func (lock *RedisLock) Transaction(transaction func(redis Redis) error) error
- func (lock *RedisLock) TryLock() error
- func (lock *RedisLock) Unlock() error
- func (lock *RedisLock) UnlockIn(redis Redis) error
- type RedisResponse
- type Storable
- type StoredObject
Constants ¶
View Source
const ( LevelOff = LogLevel(0) LevelTrace = LogLevel(5) LevelNormal = LogLevel(10) LevelWarn = LogLevel(15) )
Variables ¶
View Source
var (
L = NewLogger(LevelNormal)
)
View Source
var ( LevelNames = map[LogLevel]string{ LevelOff: " Off", LevelTrace: "Trace", LevelNormal: " Log", LevelWarn: " Warn", } )
View Source
var LockFailed = errors.New("Failed to acquire lock")
View Source
var (
PrettyJson = true
)
Functions ¶
func EnableResponseLogging ¶
func EnableResponseLogging()
func EndpointLockValue ¶
Return a string that is unique per client/endpoint. addr should contain service port.
func FillFromMap ¶
func FloatBytes ¶
func Http_application_error ¶
func Http_application_error(w http.ResponseWriter, r *http.Request, err error)
func Http_check_response ¶
func Http_get_json ¶
func Http_get_json_map ¶
func Http_json_map_response ¶
func Http_json_response ¶
func Http_respond ¶
func Http_respond_error ¶
func Http_respond_json ¶
func Http_respond_json(w http.ResponseWriter, r *http.Request, value interface{})
func Http_simple_post ¶
func MakeHttpResponse ¶
func MatchFormKeys ¶
func ParseBalanceEndpointsFlags ¶
func ParseBalanceEndpointsFlags()
func ParseLoadBalanceConfig ¶
func ParseLoadBalanceConfig()
func RegisterLockScripts ¶
Types ¶
type HttpError ¶
type HttpError struct {
// contains filtered or unexported fields
}
This is a way for the application to control the http response code, if the controller is willing to evaluate it
func HttpErrorf ¶
type HttpStatusError ¶
func (*HttpStatusError) Error ¶
func (err *HttpStatusError) Error() string
type Redis ¶
type Redis interface { Cmd(cmd string, args ...interface{}) RedisResponse Transaction(transaction func(redis Redis) error) error StoreStruct(key string, obj interface{}) error LoadStruct(key string, obj interface{}) error }
func ConnectRedis ¶
type RedisLock ¶
type RedisLock struct { Client Redis LockName string LockValue string // Should be unique per client Expiration time.Duration Retry uint }
func (*RedisLock) ExtendTransaction ¶
Assume lock is already locked! Instead of unlocking in the end, make sure that we still own the lock and extend the timeout
func (*RedisLock) Transaction ¶
At the end of the transaction, unlock the lock and make sure it is still owned by us
type RedisResponse ¶
type StoredObject ¶
type StoredObject struct {
S Storable
}
func (*StoredObject) Exists ¶
func (stored *StoredObject) Exists() (bool, error)
func (*StoredObject) Load ¶
func (stored *StoredObject) Load() error
func (*StoredObject) LoadExisting ¶
func (stored *StoredObject) LoadExisting() (bool, error)
func (*StoredObject) Save ¶
func (stored *StoredObject) Save() error
func (*StoredObject) SaveIn ¶
func (stored *StoredObject) SaveIn(redis Redis) error
Source Files ¶
Click to show internal directories.
Click to hide internal directories.