0
0
Microservicessystem_design~10 mins

Eventual consistency handling in Microservices - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to identify the consistency model used in microservices.

Microservices
if system.consistency == '[1]':
    print("Updates will be visible eventually.")
Drag options to blanks, or click blank then click option'
Astrong consistency
Bimmediate consistency
Ceventual consistency
Dstrict consistency
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing strong consistency which requires immediate update visibility.
2fill in blank
medium

Complete the code to implement a retry mechanism for eventual consistency.

Microservices
def update_service(data):
    try:
        send_update(data)
    except [1]:
        retry_later(data)
Drag options to blanks, or click blank then click option'
AKeyError
BValueError
CSyntaxError
DTimeoutError
Attempts:
3 left
💡 Hint
Common Mistakes
Using ValueError which is unrelated to network issues.
3fill in blank
hard

Fix the error in the code that handles event ordering for eventual consistency.

Microservices
def process_event(event):
    if event.timestamp [1] last_processed_timestamp:
        apply_event(event)
        last_processed_timestamp = event.timestamp
Drag options to blanks, or click blank then click option'
A>=
B>
C<
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' which processes older events incorrectly.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that filters events newer than a timestamp.

Microservices
filtered_events = {e.id: e for e in events if e.timestamp [1] cutoff_timestamp and e.status [2] 'pending'}
Drag options to blanks, or click blank then click option'
A>
B==
C!=
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' for timestamp which selects older events.
5fill in blank
hard

Fill all three blanks to build a dictionary comprehension that maps event keys to values for confirmed events after a timestamp.

Microservices
confirmed_events = {event.[1]: event.[2] for event in event_list if event.[3] > last_sync_time}
Drag options to blanks, or click blank then click option'
Akey
Bvalue
Ctimestamp
Dstatus
Attempts:
3 left
💡 Hint
Common Mistakes
Using status instead of timestamp for filtering.