我正在從紅寶石背景中學習Erlang,並且難以理解思維過程。我試圖解決的問題如下:我需要對api發出同樣的請求,每次我在響應中收到一個唯一的ID,我需要傳入下一個請求,直到沒有返回ID。從每個響應中我需要提取某些數據並將其用於其他事情。erlang,從元組列表中提取值連續
首先得到該迭代器:
ShardIteratorResponse = kinetic:get_shard_iterator(GetShardIteratorPayload).
{ok,[{<<"ShardIterator">>,
<<"AAAAAAAAAAGU+v0fDvpmu/02z5Q5OJZhPo/tU7fjftFF/H9M7J9niRJB8MIZiB9E1ntZGL90dIj3TW6MUWMUX67NEj4GO89D"...>>}]}
解析出shard_iterator ..
{_, [{_, ShardIterator}]} = ShardIteratorResponse.
請對室壁運動的流記錄的請求......
GetRecordsPayload = [{<<"ShardIterator">>, <<ShardIterator/binary>>}].
[{<<"ShardIterator">>,
<<"AAAAAAAAAAGU+v0fDvpmu/02z5Q5OJZhPo/tU7fjftFF/H9M7J9niRJB8MIZiB9E1ntZGL90dIj3TW6MUWMUX67NEj4GO89DETABlwVV"...>>}]
14> RecordsResponse = kinetic:get_records(GetRecordsPayload).
{ok,[{<<"NextShardIterator">>,
<<"AAAAAAAAAAFy3dnTJYkWr3gq0CGo3hkj1t47ccUS10f5nADQXWkBZaJvVgTMcY+nZ9p4AZCdUYVmr3dmygWjcMdugHLQEg6x"...>>},
{<<"Records">>,
[{[{<<"Data">>,<<"Zmlyc3QgcmVjb3JkISEh">>},
{<<"PartitionKey">>,<<"BlanePartitionKey">>},
{<<"SequenceNumber">>,
<<"49545722516689138064543799042897648239478878787235479554">>}]}]}]}
我我正在努力的是如何編寫一個循環,不斷打擊該流的kinesis端點,直到沒有mor e分片迭代器...又名我想要所有記錄。因爲我不能重新分配變量,因爲我會在紅寶石...任何幫助指導讚賞!