// ListKeys is used to list all keys with a given prefix to a seperator func (k *KVS) ListKeys(args *structs.KeyListRequest, reply *structs.IndexedKeyList) error { if done, err := k.srv.forward("KVS.ListKeys", args, args, reply); done { return err } acl, err := k.srv.resolveToken(args.Token) if err != nil { return err } // Get the local state state := k.srv.fsm.State() opts := blockingRPCOptions{ queryOpts: &args.QueryOptions, queryMeta: &reply.QueryMeta, kvWatch: true, kvPrefix: args.Prefix, run: func() error { index, keys, err := state.KVSListKeys(args.Prefix, args.Seperator) reply.Index = index if acl != nil { keys = FilterKeys(acl, keys) } reply.Keys = keys return err }, } return k.srv.blockingRPCOpt(&opts) }
// ListKeys is used to list all keys with a given prefix to a seperator func (k *KVS) ListKeys(args *structs.KeyListRequest, reply *structs.IndexedKeyList) error { if done, err := k.srv.forward("KVS.ListKeys", args, args, reply); done { return err } acl, err := k.srv.resolveToken(args.Token) if err != nil { return err } // Get the local state state := k.srv.fsm.State() return k.srv.blockingRPC(&args.QueryOptions, &reply.QueryMeta, state.QueryTables("KVSListKeys"), func() error { index, keys, err := state.KVSListKeys(args.Prefix, args.Seperator) reply.Index = index if acl != nil { keys = FilterKeys(acl, keys) } reply.Keys = keys return err }) }
// ListKeys is used to list all keys with a given prefix to a separator. func (k *KVS) ListKeys(args *structs.KeyListRequest, reply *structs.IndexedKeyList) error { if done, err := k.srv.forward("KVS.ListKeys", args, args, reply); done { return err } acl, err := k.srv.resolveToken(args.Token) if err != nil { return err } // Get the local state state := k.srv.fsm.State() return k.srv.blockingRPC( &args.QueryOptions, &reply.QueryMeta, state.GetKVSWatch(args.Prefix), func() error { index, keys, err := state.KVSListKeys(args.Prefix, args.Seperator) if err != nil { return err } // Must provide non-zero index to prevent blocking // Index 1 is impossible anyways (due to Raft internals) if index == 0 { reply.Index = 1 } else { reply.Index = index } if acl != nil { keys = FilterKeys(acl, keys) } reply.Keys = keys return nil }) }