Python functions as REST objects, with clustering, load balancing and state replication; no containers or orchestration.

0 downloads

dbbasic-object-primitive/test_log_replication_live.py
Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-object-primitive.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-object-primitive.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-object-primitive.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

Dan Q Consolidate duplicate QUICKSTARTs on the top-level file 503f830 7 months ago History
test_log_replication_live.py · 1.3 KB · 41 lines
1#!/usr/bin/env python3
2"""
3Test log replication in live cluster
4"""
5from dbbasic_object_core.core.self_logger import SelfLogger
6from cluster_config import get_config
7import time
8
9# Create logger with replication enabled
10logger = SelfLogger('test_replication', base_dir='data', enable_replication=True)
11
12print("Creating log entries with replication enabled...")
13logger.info("First log entry from station1", test_number=1)
14time.sleep(1)
15
16logger.info("Second log entry from station1", test_number=2)
17time.sleep(1)
18
19logger.warning("Third entry - warning level", test_number=3)
20time.sleep(1)
21
22logger.error("Fourth entry - error level", test_number=4, extra_data="testing")
23time.sleep(1)
24
25logger.info("Fifth and final entry", test_number=5)
26
27print("✓ Created 5 log entries with replication")
28print("Waiting 3 seconds for replication to complete...")
29time.sleep(3)
30
31# Show local logs
32logs = logger.get_logs()
33print(f"\n✓ Local logs on station1: {len(logs)} entries")
34for log in logs:
35 print(f" - {log['timestamp'][:19]} [{log['level']}] {log['message']} (entry_id: {log['entry_id'][:8]}...)")
36
37print("\nNow check logs on worker stations:")
38config = get_config()
39for worker in config.get_workers():
40 url = config.get_url(worker['station_id'], '/objects/test_replication?logs=true')
41 print(f" curl -s {url}")