utils

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeBSON

func DecodeBSON(d interface{}, val interface{}) (err error)

DecodeBSON decodes bson type d to object val parameter val must be structure or pointer of structure

func DecodeBSONSlice

func DecodeBSONSlice(dSlice []interface{}, val interface{}) (err error)

DecodeBSONSlice decodes bson type dSlice to object val parameter val must be slice of structure or slice of structure pointer

func GenerateAccessKey

func GenerateAccessKey(lengthArg ...uint8) []byte

func GenerateStringAccessKey

func GenerateStringAccessKey(lengthArg ...uint8) string

func NumKiloString

func NumKiloString(n uint64) string

func NumMetaKiloString

func NumMetaKiloString(n uint64) string

func NumMetaString

func NumMetaString(n uint64) string

func TimeBetween

func TimeBetween(t time.Time, start *time.Time, end *time.Time) bool

TimeBetween returns true if t is between start and end start=nil means -∞, end=nil means ∞

func TimeDayAt

func TimeDayAt(t time.Time, offset time.Duration) time.Time

TimeDayAt returns the result of rounding t down to the nearest multiple of a day

func TimeHourAt

func TimeHourAt(t time.Time) time.Time

TimeHourAt returns the result of rounding t down to the nearest multiple of a hour

func TimeMinuteAt

func TimeMinuteAt(t time.Time) time.Time

TimeMinuteAt returns the result of rounding t down to the nearest multiple of a minute

func TimeMonthAt

func TimeMonthAt(t time.Time, offset time.Duration) time.Time

TimeMonthAt returns the result of rounding t down to the nearest multiple of a month

func TimeParseAny

func TimeParseAny(value string) (*time.Time, error)

TimeParseAny parses string with any common format to time.Time

func TimeSecondAt

func TimeSecondAt(t time.Time) time.Time

TimeSecondAt returns the result of rounding t down to the nearest multiple of a second

Types

type Authorization

type Authorization struct {
	*Credential
	// contains filtered or unexported fields
}

func NewAuthorization

func NewAuthorization(cred *Credential) *Authorization

func (*Authorization) CheckPermission

func (authorization *Authorization) CheckPermission(perm int32) bool

func (*Authorization) IsAuthorized

func (authorization *Authorization) IsAuthorized() bool

func (*Authorization) PopPermission

func (authorization *Authorization) PopPermission() (perm int32, err error)

func (*Authorization) PushPermission

func (authorization *Authorization) PushPermission(perm int32) (err error)

type Clicker

type Clicker interface {
	Now() time.Time
}

type ClockGenerator

type ClockGenerator struct {
	// contains filtered or unexported fields
}

func NewClockGenerator

func NewClockGenerator(clock Clicker, d time.Duration, bufferSize ...uint16) (clockGenerator *ClockGenerator)

NewClockGenerator returns a new channel type clock pulse generator with given duration and bufferSize

func (*ClockGenerator) Channel

func (clockGenerator *ClockGenerator) Channel() <-chan time.Time

func (*ClockGenerator) Receive

func (clockGenerator *ClockGenerator) Receive(ctx context.Context) (t time.Time, ok bool)

func (*ClockGenerator) Stop

func (clockGenerator *ClockGenerator) Stop()

type Credential

type Credential struct {
	AccessKey []byte
	// contains filtered or unexported fields
}

func NewCredentialFromKnownAccessKey

func NewCredentialFromKnownAccessKey(accessKey []byte, secretLength ...int) (credential *Credential)

func NewCredentialFromKnownAccessKeyChain

func NewCredentialFromKnownAccessKeyChain(accessKey ...string) (credential *Credential)

func NewCredentialFromKnownStringAccessKey

func NewCredentialFromKnownStringAccessKey(accessKey string, secretLength ...int) (credential *Credential)

func (*Credential) AccessKeys

func (credential *Credential) AccessKeys() [][]byte

func (*Credential) Append

func (credential *Credential) Append(next *Credential) (newCredential *Credential)

func (*Credential) Attach

func (credential *Credential) Attach(next *Credential)

func (*Credential) Clone

func (credential *Credential) Clone() *Credential

func (*Credential) ID

func (credential *Credential) ID() []byte

func (*Credential) StringAccessKeys

func (credential *Credential) StringAccessKeys() []string

func (*Credential) StringID

func (credential *Credential) StringID() string

func (*Credential) StringToken

func (credential *Credential) StringToken() string

func (*Credential) Token

func (credential *Credential) Token() []byte

type CredentialChain

type CredentialChain = *Credential

func CredentialChainFromToken

func CredentialChainFromToken(token []byte, levelParam ...int) CredentialChain

type KVPairs

type KVPairs []kvPair

func (KVPairs) Get

func (pairs KVPairs) Get(key string) (val interface{}, ok bool)

func (KVPairs) Set

func (pairs KVPairs) Set(key string, val interface{}) (newPairs KVPairs)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL