Ejemplo n.º 1
0
// Some events pushed to Slack require an ID that is always incrementing,
// the Snowflake ID generator is perfect for this.
func init() {
	snowflake, err := gosnow.Default()
	if err != nil {
		panic(err)
	}

	sf = snowflake
}
Ejemplo n.º 2
0
func init() {
	gosnow.Since = Epoch.UnixNano() / 1000000
	var err error
	DefaultSnowflaker, err = gosnow.Default()
	if err != nil {
		panic(err)
	}
}
Ejemplo n.º 3
0
func main() {

	v := gosnow.Default()
	//v := gosnow.NewSnowFlake(100)
	for i := 0; i < 10; i++ {
		id := v.Next()
		fmt.Println(id)
	}
}
func NewTimelineRiakDaoImpl(cluster *riak.Cluster, indexBucket string, logBucket string, daysToKeep int) *TimelineRiakDaoImpl {
	snowFlake, _ := gosnow.Default()
	return &TimelineRiakDaoImpl{
		Cluster:      cluster,
		IndexDao:     NewLogIndexRiakDAO(cluster, indexBucket),
		LogRecordDao: NewLogRecordRiakDao(cluster, logBucket),
		SnowFlake:    snowFlake,
		DaysToKeep:   daysToKeep,
	}
}
Ejemplo n.º 5
0
func NewConnectionManager() *ConnectionManager {
	v, err := gosnow.Default()
	//v, err := gosnow.NewSnowFlake(100)
	if err != nil {
		panic("snowflake init error, msgid can not get!")
	}

	return &ConnectionManager{

		clients: make(map[string]*Client),

		sf: v,
	}

}