File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 1919@random_greeter .handler ()
2020async def greet (ctx : Context , name : str ) -> str :
2121
22+ # ctx.random() returns a Python Random instance seeded deterministically.
23+ # By using ctx.random() you don't write entries in the journal, while getting the same generated values on retries.
24+
25+ # You can ctx.random() to generate random numbers using ctx.random().randint()
2226 random_number = ctx .random ().randint (0 , 100 )
27+
28+ # Or random bytes using ctx.random().randbytes()
29+ random_bytes = ctx .random ().randbytes (10 )
30+
31+ # Use ctx.uuid() to generate a UUID v4 seeded deterministically
32+ # As with ctx.random(), this won't write entries in the journal
2333 random_uuid = ctx .uuid ()
2434
25- return f"Hello { name } with random number { random_number } and uuid { random_uuid } !"
35+ return f"Hello { name } with random number { random_number } , random bytes { random_bytes } and uuid { random_uuid } !"
You can’t perform that action at this time.
0 commit comments