code: func (ss *RaftSubStore) CreateSub(sub *spb.SubState) error {
  	gss := &ss.genericSubStore
  
  	gss.Lock()
  	defer gss.Unlock()
  
  	// This store does not persist subscriptions, since it is done
  	// in the actual RAFT log. This is just a wrapper to the streaming
  	// sub store. We still need to apply limits.
  
  	// If sub.ID is provided, check if already present, in which case
  	// don't check limit.
  	if sub.ID > 0 {
  		if _, ok := gss.subs[sub.ID]; ok {
  			return nil
  		}
  	}
  	// Check limits
  	if gss.limits.MaxSubscriptions > 0 && len(gss.subs) >= gss.limits.MaxSubscriptions {
  		return ErrTooManySubs
  	}
  
  	// With new server, the sub.ID is set before this call is invoked,
  	// and if that is the case, this is what we use. But let's support
  	// not having one (in case we recover an existing store, or run a
  	// mix of servers with different versions where the leader would
  	// not be at a version that sets the sub.ID).
  	if sub.ID == 0 {
  		gss.maxSubID++
  		sub.ID = gss.maxSubID
  	} else if sub.ID > gss.maxSubID {
  		gss.maxSubID = sub.ID
  	}
  	gss.subs[sub.ID] = emptySub
  
  	return nil
  }
docs: ////////////////////////////////////////////////////////////////////////////
  // RaftSubStore methods
  ////////////////////////////////////////////////////////////////////////////
  // CreateSub implements the SubStore interface