Skip to content

Instantly share code, notes, and snippets.

@braoru
Created April 6, 2016 12:25
Show Gist options
  • Save braoru/5b16b395787e393024b97f14d537bca7 to your computer and use it in GitHub Desktop.
Save braoru/5b16b395787e393024b97f14d537bca7 to your computer and use it in GitHub Desktop.
@classmethod
def instances(
cls,
riak_client=None,
component_name='',
revers_index_name='keys',
debug=False
):
ping_result = riak_client.ping()
if debug:
pprint("Riak connectivity")
pprint("-----------------")
pprint("Can connect to ring : {r}".format(r=ping_result))
bucket_name = cls.component_bucket_name(component_name)
if debug:
pprint("Bucket to read")
pprint("--------------")
pprint(bucket_name)
bucket = riak_client.bucket(bucket_name)
sets_buckets = riak_client.bucket_type("sets")
identifier_set = sets_buckets.bucket(bucket_name).get(revers_index_name)
data = [
bucket.get(element).data for element in identifier_set
]
if debug:
pprint("Data")
pprint("----")
print(
json.dumps(
data,
sort_keys=True,
indent=4,
separators=(',', ': ')
)
)
return data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment