// NewEventStore creates a new EventStore.
546560
func NewEventStore(url, dbPrefix string) (*EventStore, error) {
	session, err := mgo.Dial(url)
	if err != nil {
		return nil, ErrCouldNotDialDB
	}

	session.SetMode(mgo.Strong, true)
	session.SetSafe(&mgo.Safe{W: 1})

	return NewEventStoreWithSession(session, dbPrefix)
}
847896
func NewResourceStore() *ResourceStore {
	return &ResourceStore{
		SecretStore:    make(map[string]*corev1.Secret),
		ConfigMapStore: make(map[string]*corev1.ConfigMap),
	}
}
759343
func NewEvent(category string, action string) *Event {
	h := &Event{
		category: category,
		action:   action,
	}
	return h
}
1115242
func NewLogDatastore(ds Datastore, name string) *LogDatastore {
	if len(name) < 1 {
		name = "LogDatastore"
	}
	return &LogDatastore{Name: name, child: ds}
}
4132
func NewGlobalStore() *GlobalStore {
	return &GlobalStore{
		nodeKeys: make(map[common.Address][][]byte),
		keyNodes: make(map[string][]common.Address),
		nodes:    make([]common.Address, 0),
		keys:     make([][]byte, 0),
		data:     make(map[string][]byte),
	}
}
654721
func NewCallerStore(c session.Caller, storeID string) content.Store {
	client := api.NewContentClient(c.Conn())
	return &callerContentStore{
		store:   proxy.NewContentStore(client),
		storeID: storeID,
	}
}
1087259
func newEvent(typ string, value interface{}, prevValue interface{}) *event {
	return &event{
		typ:       typ,
		value:     value,
		prevValue: prevValue,
	}
}
81463
func (em *EventManager) NewEvent(evtype, evselector string) (EventSubs, bool) {
	eo := BuildEventID(evtype, evselector)

	if em.HasEvent(eo) {
		ed, _ := em.GetEvent(eo)
		return ed, false
	}

	emo := NewEventSub(evtype, evselector)

	em.AddEvent(emo)
	return emo, true
}
496526
func (s *EventStore) RenameEvent(ctx context.Context, from, to eh.EventType) error {
	sess := s.session.Copy()
	defer sess.Close()

	// Find and rename all events.
	// TODO: Maybe use change info.
	if _, err := sess.DB(s.dbName(ctx)).C("events").UpdateAll(
		bson.M{
			"events.event_type": string(from),
		},
		bson.M{
			"$set": bson.M{"events.$.event_type": string(to)},
		},
	); err != nil {
		return eh.EventStoreError{
			BaseErr:   err,
			Err:       ErrCouldNotSaveAggregate,
			Namespace: eh.NamespaceFromContext(ctx),
		}
	}

	return nil
}
251312
func NewEventHandler(saga Saga, commandHandler eh.CommandHandler) *EventHandler {
	return &EventHandler{
		saga:           saga,
		commandHandler: commandHandler,
	}
}
333413
func NewEventHandler(projector Projector, repo eh.ReadWriteRepo) *EventHandler {
	return &EventHandler{
		projector: projector,
		repo:      repo,
	}
}
1292749
func NewStore(config StoreConfig) *Store {
	return &Store{
		fsm:      config.FSM,
		hub:      config.Hub,
		config:   config,
		prevTime: config.FSM.GlobalTime(),
		metrics:  newMetricsCollector(),
	}
}
6435
func NewNetStore(store SyncChunkStore, nnf NewNetFetcherFunc) (*NetStore, error) {
	fetchers, err := lru.New(defaultChunkRequestsCacheCapacity)
	if err != nil {
		return nil, err
	}
	return &NetStore{
		store:             store,
		fetchers:          fetchers,
		NewNetFetcherFunc: nnf,
		closeC:            make(chan struct{}),
	}, nil
}
624700
func NewEvent(name string, data interface{}) *Event {
	return &Event{Name: name, Data: data}
}
10620
func NewCodeStore(idStore *IDStore, options CodeStoreOptions) (*CodeStore, error) {
	return newCodeStore(idStore, options)
}
1029665
func NewDatastore(path string) (ds.Datastore, error) {
	if !isDir(path) {
		return nil, fmt.Errorf("Failed to find directory at: %v (file? perms?)", path)
	}

	return &Datastore{path: path}, nil
}
940330
func New(req *http.Request, retry time.Duration) *EventSource {
	req.Header.Set("Accept", "text/event-stream")
	req.Header.Set("Cache-Control", "no-cache")

	return &EventSource{
		retry:   retry,
		request: req,
	}
}