util

package
v1.0.0-alpha2 Latest Latest
Warning

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

Go to latest
Published: May 12, 2017 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LoggingChannelModule   = "gossip/channel"
	LoggingCommModule      = "gossip/comm"
	LoggingDiscoveryModule = "gossip/discovery"
	LoggingElectionModule  = "gossip/election"
	LoggingGossipModule    = "gossip/gossip"
	LoggingMockModule      = "gossip/comm/mock"
	LoggingPullModule      = "gossip/pull"
	LoggingServiceModule   = "gossip/service"
	LoggingStateModule     = "gossip/state"
)

Module names for logger initialization.

Variables

This section is empty.

Functions

func GetDurationOrDefault

func GetDurationOrDefault(key string, defVal time.Duration) time.Duration

GetDurationOrDefault returns the Duration value from config if present otherwise default value

func GetIntOrDefault

func GetIntOrDefault(key string, defVal int) int

GetIntOrDefault returns the int value from config if present otherwise default value

func GetLogger

func GetLogger(module string, peerID string) *logging.Logger

GetLogger returns a logger for given gossip module and peerID

func GetRandomIndices

func GetRandomIndices(indiceCount, highestIndex int) []int

GetRandomIndices returns a slice of random indices from 0 to given highestIndex

func IndexInSlice

func IndexInSlice(array interface{}, o interface{}, equals Equals) int

IndexInSlice returns the index of given object o in array

func PrintStackTrace

func PrintStackTrace()

PrintStackTrace prints to stdout all goroutines

func RandomInt

func RandomInt(n int) int

RandomInt returns, as an int, a non-negative pseudo-random integer in [0,n) It panics if n <= 0

func RandomUInt64

func RandomUInt64() uint64

RandomUInt64 returns a random uint64

func SetupTestLogging

func SetupTestLogging()

SetupTestLogging sets the default log levels for gossip unit tests

Types

type Equals

type Equals func(a interface{}, b interface{}) bool

Equals returns whether a and b are the same

type MembershipStore

type MembershipStore struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

MembershipStore struct which encapsulates membership message store abstraction

func NewMembershipStore

func NewMembershipStore() *MembershipStore

NewMembershipStore creates new membership store instance

func (*MembershipStore) MsgByID

MsgByID returns a message stored by a certain ID, or nil if such an ID isn't found

func (*MembershipStore) Put

Put associates msg with the given pkiID

func (*MembershipStore) Remove

func (m *MembershipStore) Remove(pkiID common.PKIidType)

Remove removes a message with a given pkiID

func (*MembershipStore) Size

func (m *MembershipStore) Size() int

Size of the membership store

func (*MembershipStore) ToSlice

func (m *MembershipStore) ToSlice() []*proto.SignedGossipMessage

ToSlice returns a slice backed by the elements of the MembershipStore

type Set

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

Set is a generic and thread-safe set container

func NewSet

func NewSet() *Set

NewSet returns a new set

func (*Set) Add

func (s *Set) Add(item interface{})

Add adds given item to the set

func (*Set) Clear

func (s *Set) Clear()

Clear removes all elements from set

func (*Set) Exists

func (s *Set) Exists(item interface{}) bool

Exists returns true whether given item is in the set

func (*Set) Remove

func (s *Set) Remove(item interface{})

Remove removes a given item from the set

func (*Set) ToArray

func (s *Set) ToArray() []interface{}

ToArray returns a slice with items at the point in time the method was invoked

Jump to

Keyboard shortcuts

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