github.com/hdt3213/godis@v1.2.9/pubsub/hub.go (about)

     1  package pubsub
     2  
     3  import (
     4  	"github.com/hdt3213/godis/datastruct/dict"
     5  	"github.com/hdt3213/godis/datastruct/lock"
     6  )
     7  
     8  // Hub stores all subscribe relations
     9  type Hub struct {
    10  	// channel -> list(*Client)
    11  	subs dict.Dict
    12  	// lock channel
    13  	subsLocker *lock.Locks
    14  }
    15  
    16  // MakeHub creates new hub
    17  func MakeHub() *Hub {
    18  	return &Hub{
    19  		subs:       dict.MakeConcurrent(4),
    20  		subsLocker: lock.Make(16),
    21  	}
    22  }