// AllKeysChan returns a channel from which to read the keys stored in
// the FileManager. If the given context is cancelled the channel will be
// closed.
355764
func (f *FileManager) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error) {
	q := dsq.Query{KeysOnly: true}

	res, err := f.ds.Query(q)
	if err != nil {
		return nil, err
	}

	out := make(chan cid.Cid, dsq.KeysOnlyBufSize)
	go func() {
		defer close(out)
		for {
			v, ok := res.NextSync()
			if !ok {
				return
			}

			k := ds.RawKey(v.Key)
			c, err := dshelp.DsKeyToCid(k)
			if err != nil {
				log.Errorf("decoding cid from filestore: %s", err)
				continue
			}

			select {
			case out <- c:
			case <-ctx.Done():
				return
			}
		}
	}()

	return out, nil
}
127621
func (m *clientConnMap) Keys() []string {
	m.RLock()

	res := make([]string, 0, len(m.conns))
	for k := range m.conns {
		res = append(res, k)
	}

	m.RUnlock()
	return res
}
924980
func ListAllKeys(bucket s3.Bucket) (keys []string, err error) {
	for {
		var prevKey string
		if len(keys) > 0 {
			prevKey = keys[len(keys)-1]
		}

		var partialKeys []string
		partialKeys, err = bucket.ListKeys(prevKey)
		if err != nil {
			err = fmt.Errorf("ListKeys: %v", err)
			return
		}

		if len(partialKeys) == 0 {
			break
		}

		keys = append(keys, partialKeys...)
	}

	return
}
193646
func (s *RedisMapStore) GetAll(keys []string, options *ListOptions) ([]interface{}, error) {
	if len(keys) == 0 {
		return []interface{}{}, nil
	}

	for i, key := range keys {
		if !strings.HasPrefix(key, s.prefix) {
			keys[i] = s.prefix + key
		}
	}

	sort.Strings(keys)

	selectedKeys := selectKeys(keys, options)
	if len(selectedKeys) == 0 {
		return []interface{}{}, nil
	}

	pipe := s.client.Pipeline()
	defer pipe.Close()

	// Add all commands to pipeline
	cmds := make(map[string]*redis.StringStringMapCmd)
	for _, key := range selectedKeys {
		cmds[key] = pipe.HGetAll(key)
	}

	// Execute pipeline
	_, err := pipe.Exec()
	if err != nil {
		return nil, err
	}

	// Get all results from pipeline
	results := make([]interface{}, len(selectedKeys))
	for i, key := range selectedKeys {
		if result, err := cmds[key].Result(); err == nil {
			result, _ = s.migrate(key, result)
			if result, err := s.decoder(result); err == nil {
				results[i] = result
			}
		}
	}

	return results, nil
}
212130
func watchAndResyncBrokerKeys(resyncReg resync.Registration, changeChan chan datasync.ChangeEvent, resyncChan chan datasync.ResyncEvent,
	closeChan chan string, adapter *watcher, keyPrefixes ...string) (keys *watchBrokerKeys, err error) {
	keys = &watchBrokerKeys{
		resyncReg:  resyncReg,
		changeChan: changeChan,
		resyncChan: resyncChan,
		adapter:    adapter,
		prefixes:   keyPrefixes,
	}

	var wasErr error
	if err := keys.resyncRev(); err != nil {
		wasErr = err
	}
	if resyncReg != nil {
		go keys.watchResync(resyncReg)
	}
	if changeChan != nil {
		if err := keys.adapter.dbW.Watch(keys.watchChanges, closeChan, keys.prefixes...); err != nil {
			wasErr = err
		}
	}
	return keys, wasErr
}
725619
func (opts Options) GetAll(key string) []string {
	result := []string{}
	for _, o := range opts {
		if o.IsKey(key) {
			result = append(result, o.Value)
		}
	}
	return result
}
1260438
func (f *file) lintContextKeyTypes() {
	f.walk(func(node ast.Node) bool {
		switch node := node.(type) {
		case *ast.CallExpr:
			f.checkContextKeyType(node)
		}

		return true
	})
}
206835
func sortedKeys(m interface{}) []string {
	v := reflect.ValueOf(m)
	keys := make([]string, v.Len())

	mapKeys := v.MapKeys()
	for i, k := range mapKeys {
		keys[i] = k.Interface().(string)
	}

	sort.Strings(keys)
	return keys
}
98741
func (cs *CryptoService) ListAllKeys() map[string]data.RoleName {
	res := make(map[string]data.RoleName)
	for _, ks := range cs.keyStores {
		for k, r := range ks.ListKeys() {
			res[k] = r.Role // keys are content addressed so don't care about overwrites
		}
	}
	return res
}
317602
func NewClientKeyManager(trustKey PrivateKey, clientFile, clientDir string) (*ClientKeyManager, error) {
	m := &ClientKeyManager{
		key:        trustKey,
		clientFile: clientFile,
		clientDir:  clientDir,
	}
	if err := m.loadKeys(); err != nil {
		return nil, err
	}
	// TODO Start watching file and directory

	return m, nil
}
997445
func (w *deploymentWatcher) getAllocsCh(index uint64) <-chan *allocUpdates {
	out := make(chan *allocUpdates, 1)
	go func() {
		allocs, index, err := w.getAllocs(index)
		out <- &allocUpdates{
			allocs: allocs,
			index:  index,
			err:    err,
		}
	}()

	return out
}
717451
func (o Options) sortedKeys() []int {
	// Send all values for a given key
	var codes []int
	for k := range o {
		codes = append(codes, int(k))
	}

	sort.Sort(sort.IntSlice(codes))
	return codes
}
385568
func (kr *GroupResolver) RemoveAllKeys() {
	kr.Lock()
	defer kr.Unlock()
	kr.keyMap = make(map[string][]Key)
	return
}
1234537
func keyFileExists(filename string) bool {
	_, err := os.Stat(fmt.Sprintf(keysFolderPrefixFormat, filename))
	return err == nil
}
1266137
func (s *storage) RootKey() ([]byte, []byte, error) {
	storage, closer := s.getStorage()
	defer closer()
	return storage.RootKey()
}
1079383
func (s *FakeAWSServices) KeyManagement(region string) (KMS, error) {
	return s.kms, nil
}
1189476
func (st *State) AllCharms() ([]*Charm, error) {
	charmsCollection, closer := st.db().GetCollection(charmsC)
	defer closer()
	var cdoc charmDoc
	var charms []*Charm
	iter := charmsCollection.Find(nsLife.notDead()).Iter()
	for iter.Next(&cdoc) {
		ch := newCharm(st, &cdoc)
		charms = append(charms, ch)
	}
	return charms, errors.Trace(iter.Close())
}