// NewSafeID returns a new instance of an IDGenerator which is safe for
// concurrent use by multiple goroutines.
6630
func NewSafeID(startID int) IDGenerator {
	return &safeID{
		nextID: startID,
		mutex:  &sync.Mutex{},
	}
}
722051
func NewShardError(id uint64, err error) error {
	if err == nil {
		return nil
	}
	return ShardError{id: id, Err: err}
}
380907
func NewSendMessageToTargetArgs(message string) *SendMessageToTargetArgs {
	args := new(SendMessageToTargetArgs)
	args.Message = message
	return args
}
649840
func newStorageInstanceId(mb modelBackend, store string) (string, error) {
	seq, err := sequence(mb, "stores")
	if err != nil {
		return "", errors.Trace(err)
	}
	return fmt.Sprintf("%s/%v", store, seq), nil
}
81049
func NewSetInspectedNodeArgs(nodeID NodeID) *SetInspectedNodeArgs {
	args := new(SetInspectedNodeArgs)
	args.NodeID = nodeID
	return args
}
729971
func (w *WatcherDef) ParseAnnounceInterval() (err error) {
	if w.AnnounceInterval != "" {
		w.announceDuration, err = time.ParseDuration(w.AnnounceInterval)
		if err != nil {
			return errors.Wrapf(err, "unknown announce interval for watcher %s", w.Name)
		}

		if w.announceDuration < time.Minute {
			return errors.Errorf("announce interval %v is too small for watcher %s", w.announceDuration, w.Name)
		}
	}

	return nil
}
263546
func NewIDService(ctx context.Context, h host.Host) *IDService {
	s := &IDService{
		Host:          h,
		ctx:           ctx,
		currid:        make(map[inet.Conn]chan struct{}),
		observedAddrs: NewObservedAddrSet(ctx),
	}
	h.SetStreamHandler(ID, s.requestHandler)
	h.SetStreamHandler(IDPush, s.pushHandler)
	h.Network().Notify((*netNotifiee)(s))
	return s
}
1135653
func newStructDef(apiDef *raml.APIDefinition, name, packageName, description string, properties map[string]interface{}) structDef {
	// generate struct's fields from type properties
	fields := make(map[string]fieldDef)
	for k, v := range properties {
		prop := raml.ToProperty(k, v)
		fields[prop.Name] = newFieldDef(apiDef, name, prop, packageName)
	}
	return structDef{
		Name:        strings.Title(commons.NormalizeIdentifier(name)),
		PackageName: packageName,
		Fields:      fields,
		Description: commons.ParseDescription(description),
	}
}
870445
func (e *Execution) GetEID() *dm.Execution_ID {
	aid := &dm.Attempt_ID{}
	if e.ID == 0 {
		panic("cannot create valid Execution_ID with 0-value ID field")
	}
	if err := aid.SetDMEncoded(e.Attempt.StringID()); err != nil {
		panic(err)
	}
	return dm.NewExecutionID(aid.Quest, aid.Id, uint32(e.ID))
}
761
func NewService() *Service {
	s := &Service{
		TokenGenerator: rand.NewTokenGenerator(64),
		IDGenerator:    snowflake.NewIDGenerator(),
		time:           time.Now,
	}
	s.initializeSources(context.TODO())
	return s
}
75875
func NewSetGenerateCmd(generate bool, genProcLimit *int) *SetGenerateCmd {
	return &SetGenerateCmd{
		Generate:     generate,
		GenProcLimit: genProcLimit,
	}
}
967033
func NewStruct(s interface{}, tagid string) (*StructStruct, error) {
	if s, ok := s.(*StructStruct); ok {
		return s, nil
	}

	v := reflect.ValueOf(s)
	if v.Kind() != reflect.Ptr {
		return nil, errNoPointer
	}
	if v.Elem().Kind() != reflect.Struct {
		return nil, errNoStruct
	}

	return &StructStruct{
		name:  fmt.Sprintf("%T", s),
		raw:   s,
		value: v,
		data:  fieldsOf(s, tagid),
	}, nil
}
318885
func NewService() (s *Service, err error) {
	s = &Service{}
	s.ID, err = utils.NewUUID36()
	return s, err
}
1290192
func NewStatsdProvider(s *statsd.Statsd, stop func()) Provider {
	return &statsdProvider{
		s:    s,
		stop: stop,
	}
}
1083552
func (n *Notifier) Notify(id ID, data interface{}) error {
	enc, err := json.Marshal(data)
	if err != nil {
		return err
	}

	n.mu.Lock()
	defer n.mu.Unlock()

	if n.sub == nil {
		panic("can't Notify before subscription is created")
	} else if n.sub.ID != id {
		panic("Notify with wrong ID")
	}
	if n.activated {
		return n.send(n.sub, enc)
	}
	n.buffer = append(n.buffer, enc)
	return nil
}
190094
func (s *AwsSecurityFindingFilters) SetGeneratorId(v []*StringFilter) *AwsSecurityFindingFilters {
	s.GeneratorId = v
	return s
}
598360
func (c *Client) NewSetClientIdRequest(clientId string) *RpbSetClientIdReq {
	return &RpbSetClientIdReq{
		ClientId: []byte(clientId),
	}
}