Example #1
0
func newPublication(name string) *publication {
	if name == "recvPull" || name == "recvPull2" {
		p := &publication{}
		p.name, p.gid = name, uint64(time.Now().UnixNano())
		p.rpc = true
		p.closed = false
		p.master, p.slaves = nil, nil
		if name != "recvPull2" {
			p.reliable = true
		} else {
			p.reliable = false
		}
		return p
	}

	bid := utils.Hash16S(name) % uint16(len(streams.buckets))

	b := &streams.buckets[bid]
	b.Lock()
	p := b.pubmap[name]
	if p == nil {
		p = &publication{}
		p.name, p.gid = name, uint64(time.Now().UnixNano())
		p.rpc = false
		p.closed = false
		p.master, p.slaves = nil, list.New()
		p.bid = bid
		p.reliable = true
		b.pubmap[name] = p
	}
	b.Unlock()
	return p
}
Example #2
0
func hashPidToBid(pid string) uint16 {
	return utils.Hash16S(pid) % uint16(len(sessions.buckets))
}