func (s *Server) Bucket(subKey string) *Bucket {
	idx := cityhash.CityHash32([]byte(subKey), uint32(len(subKey))) % s.bucketIdx
	if conf.Conf.Debug {
		log.Infof("%s hit channel bucket index: %d use cityhash", subKey, idx)
	}
	return s.buckets[idx]
}
Bucket get the bucket by subkey.
package comet
import (
	"context"
	"math/rand"
	"time"
	log "github.com/tsingson/zaplogger"
	"github.com/zhenjl/cityhash"
	logic "github.com/tsingson/ex-goim/api/logic/grpc"
	"github.com/tsingson/ex-goim/goim-nats/comet/conf"
)
const (
	minServerHeartbeat = time.Minute * 10
	maxServerHeartbeat = time.Minute * 30
)
type Server struct {
	c         *conf.CometConfig
	round     *Round     
	buckets   []*Bucket  
	bucketIdx uint32
	serverID  string
	rpcClient logic.LogicClient
}
func NewServer(cfg *conf.CometConfig) *Server {
	s := &Server{
		c:         cfg,
		round:     NewRound(cfg),
		rpcClient: NewLogicClient(cfg.RPCClient),
	}
	s.buckets = make([]*Bucket, cfg.Bucket.Size)
	s.bucketIdx = uint32(cfg.Bucket.Size)
	for i := 0; i < cfg.Bucket.Size; i++ {
		s.buckets[i] = NewBucket(cfg.Bucket)
	}
	s.serverID = cfg.Env.Host
	go s.onlineproc()
	return s
}
func (s *Server) Buckets() []*Bucket {
	return s.buckets
}