0
0
Microservicessystem_design~10 mins

Event store concept 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 define an event in the event store.

Microservices
event = {"type": "UserCreated", "data": [1]
Drag options to blanks, or click blank then click option'
A[123, "Alice"]
B{"userId": 123, "name": "Alice"}
C"UserCreated"
D123
Attempts:
3 left
💡 Hint
Common Mistakes
Using a list or string instead of a dictionary for event data.
2fill in blank
medium

Complete the code to append an event to the event store.

Microservices
event_store.append([1])
Drag options to blanks, or click blank then click option'
Aevent
Bevent_store
Cevent.data
Devent.type
Attempts:
3 left
💡 Hint
Common Mistakes
Appending only event type or event data instead of the full event.
3fill in blank
hard

Fix the error in the code to read events from the event store.

Microservices
for [1] in event_store:
    print(event)
Drag options to blanks, or click blank then click option'
Aevent
Bevents
Ce
Devent_store
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different variable name in the loop and print statement.
4fill in blank
hard

Fill both blanks to filter events of type 'OrderPlaced' from the event store.

Microservices
filtered_events = [event for event in event_store if event[1] [2] 'OrderPlaced']
Drag options to blanks, or click blank then click option'
A.type
B==
C!=
D.data
Attempts:
3 left
💡 Hint
Common Mistakes
Using '!=' instead of '==' or accessing wrong attribute.
5fill in blank
hard

Fill all three blanks to create a dictionary of event counts by type.

Microservices
event_counts = [1](event.type for event in event_store if event.type[2] [3])
Drag options to blanks, or click blank then click option'
ACounter
B!=
C'UserDeleted'
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' instead of '!=' for filtering, or missing Counter import.