MCPcopy Create free account
hub / github.com/ExtendDB/extenddb / main

Function main

samples/stream_consumer.py:182–221  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

180
181 log("POLLER", f"Done. Total records seen: {records_seen}")
182def main() -> None:
183 client = make_client()
184
185 log("MAIN ", f"Creating table {TABLE_NAME} with streams (NEW_AND_OLD_IMAGES)...")
186 client.create_table(
187 TableName=TABLE_NAME,
188 AttributeDefinitions=[{"AttributeName": "pk", "AttributeType": "S"}],
189 KeySchema=[{"AttributeName": "pk", "KeyType": "HASH"}],
190 BillingMode="PAY_PER_REQUEST",
191 StreamSpecification={
192 "StreamEnabled": True,
193 "StreamViewType": "NEW_AND_OLD_IMAGES",
194 },
195 )
196 wait_for_active(client, TABLE_NAME)
197 log("MAIN ", "Table ACTIVE.")
198
199 try:
200 poller = threading.Thread(target=poller_thread, name="poller", daemon=True)
201 writer = threading.Thread(target=writer_thread, name="writer")
202
203 poller.start()
204 time.sleep(1) # Let poller discover shards before writes begin
205 writer.start()
206
207 writer.join()
208
209 # Give poller time to drain remaining records
210 log("MAIN ", "Writer done. Giving poller 5s to drain...")
211 time.sleep(5)
212 stop_poller.set()
213 poller.join(timeout=3)
214
215 log("MAIN ", "Demo complete.")
216 finally:
217 log("MAIN ", f"Deleting table {TABLE_NAME}...")
218 try:
219 client.delete_table(TableName=TABLE_NAME)
220 except Exception:
221 pass
222if __name__ == "__main__":
223 main()

Callers 1

stream_consumer.pyFile · 0.70

Calls 5

logFunction · 0.85
create_tableMethod · 0.80
delete_tableMethod · 0.80
make_clientFunction · 0.70
wait_for_activeFunction · 0.70

Tested by

no test coverage detected