Documentation
¶
Index ¶
- Constants
- func CapFirst(str string) string
- func Hash(aSeed int, aObject interface{}) int
- func HashBase(aSeed int, a Base) int
- func HashBool(aSeed int, aBoolean bool) int
- func HashBytes(aSeed int, aBytes []byte) int
- func HashDouble(aSeed int, aDouble float64) int
- func HashFloat(aSeed int, aFloat float32) int
- func HashInt(aSeed int, aInt int) int
- func HashInteger(aSeed int, aInt int32) int
- func HashLong(aSeed int, aLong int64) int
- func HashShort(aSeed int, aInt int16) int
- func HashString(aSeed int, aString string) int
- func HashTiny(aSeed int, aInt int8) int
- func HashType(aSeed int, aType interface{}) int
- func HashUnit(aSeed int, aInt byte) int
- func LoadConfiguration(config interface{}, file string, mandatory bool) error
- func Match(o1, o2 interface{}) bool
- func Milliseconds() int64
- func Set(instance interface{}, value interface{})
- func SliceContains(list interface{}, elem interface{}) bool
- func ToString(v interface{}) string
- func UncapFirst(str string) string
- type Base
- type Clonable
- type Codec
- type Equaler
- type Fail
- type Fault
- type GobCodec
- type Hasher
- type Joiner
- type JsonCodec
- type LazyString
- type Rate
- type RateLimiter
- type StrBuffer
- func (s *StrBuffer) Add(a ...interface{}) *StrBuffer
- func (s *StrBuffer) Addf(template string, a ...interface{}) *StrBuffer
- func (s *StrBuffer) Clear()
- func (s *StrBuffer) Clone() interface{}
- func (s *StrBuffer) Equals(e interface{}) bool
- func (s *StrBuffer) HashCode() int
- func (s *StrBuffer) IsEmpty() bool
- func (s *StrBuffer) Size() int
- func (s *StrBuffer) String() string
- type UUID
Constants ¶
const HASH_SEED = 23
*
- An initial value for a <code>hashCode</code>, to which is added contributions
- from fields. Using a non-zero value decreases collisons of <code>hashCode</code>
- values.
const UUID_SIZE = 16
Variables ¶
This section is empty.
Functions ¶
func HashDouble ¶
func HashInteger ¶
func HashString ¶
func LoadConfiguration ¶
LoadConfiguration configuration from a json file config is a pointer to a configuration variable file is the json file location
func Milliseconds ¶
func Milliseconds() int64
func SliceContains ¶
func SliceContains(list interface{}, elem interface{}) bool
func UncapFirst ¶
UncapFirst returns the input string with the first letter in lower case
Types ¶
type Fail ¶
func (*Fail) GetMessage ¶
type LazyString ¶
type LazyString func() string
LazyString enable us to use a function in fmt.(S)Printf eg: fmt.Printf(
"Hello %s", LazyString(func() string { return "world!" }),
)
func (LazyString) String ¶
func (ls LazyString) String() string
type RateLimiter ¶
RateLimiter is a simple implementation of the Leaky Bucket algorithm.
Simple use: var rl = NewRateLimiter(2) // per second
for i := 0; i < 10; i++ { var wait = rl.Take() fmt.Println(time.Now(), wait) }
func NewRateLimiter ¶
func NewRateLimiter(rate int64) *RateLimiter
NewRateLimiter creates an instance of RateLimiter rate sets the number of takes that can occur per second
func (*RateLimiter) TakeN ¶
func (rl *RateLimiter) TakeN(amount int64) time.Duration
TakeN enforces the rate limit. amount is the value over which we apply the rate and it returns the time waiting before returning. If previous calls to TakeN() had the consequence of breaking the rate limit, then the current call will wait until the rate is again below the rate limit. If we want to limit a stream of data to 4Kb/s we do the following: var rl = NewRateLimiter(4000) // per second func submit(data []byte)
rl.Take(len(data)) service.send(data); }
type StrBuffer ¶
type StrBuffer struct {
// contains filtered or unexported fields
}
func NewStrBuffer ¶
func NewStrBuffer(str ...interface{}) *StrBuffer