A FIFO (First in first out) queue has two main methods:
put()
, with puts an element to the queue,get()
, which returns next element.
If queue is empty, get()
blocks.
-----BEGIN PGP PUBLIC KEY BLOCK----- | |
mQGNBGCG8nABDACaWwPzmW1Cn1Z4YddKly4ljJyK86xQExW2F00zyqwnpV1V01e4 | |
1WIGKndRsT3QLxsnyxhfBENvf/tEyB/PHE/ujVE7+ZJliazWFaWa8wmC7gfgdxGE | |
QkTqVx5orKp+KSJKPtFGUr/6mSqiKcLv2HjyEciVDu31k+0qLqQeAaWqU33tgref | |
bpbjI3Qil9El6+dwjY/5ICRCfm4l7MLBoHR94PsRWuhnEUC6/UjyjdPjyyCKb/dm | |
fo5aFx+ibpal16SVsPffPjmZg0WG4vjrfyiomRazn27n0i0j4hL2jh6fzNJty0oe | |
U4QjakZmFp28sRhtyulTKvPBN/HlVrbz3bzhZa1xLPkM6PsgsZNZ76AaZFmeJ3qv | |
e3mYKHOVoKqywNMS4P3bOd7seJSeVwKqUHxU4fX2yXkVYHtMYStuiWDeX3pap2Y2 | |
jlXzA/S/kN+EqQD9rElmsNoQVyWjibwikpf601E4I0fHmJugcaIrsNQDUOUZd7/R |
Suppose you have a remote system behind an API. The system is reactive: you send something to it, and it is expected to do something in result. There is an API endpoint (sink) that receives requests and a callback (source) that sends responses.
Sink is just a python function that eventually calls an http endpoint. Source could be implemented as webhook or a generator, but we'll focus on the latter case.
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC8tWC2RnWqGNzcsZRkvi2TGltGf+zyM+9w9A2LHqeG8UnVy3/Pu+njmz3I6GWLGOXrRUU5HGJdTxl2UG7qVgMVVVjVwrV9EOgj4We5e6kYNUnCay9sVIgKRpxJeNo1mwBHEXzryAoNNbgGCMTpA+kEc8SAMAsoahFP/nHdYZqRXd5UxG25AmpczOe6FiaktyUjinfTnfMVAGVvrEm7OVgeXfUriBp6Mjjg9ZRHc02f3miHMywFZWkxqaEkTsM0gubymt8ivXGbY8p7/Gk2xpF958yACoZXvxH7amyUekaDKAE2S8Xhur+HeGZTw/YCbCDQZ0iA/MCBNkAmOu0/1Zppdip8rBhT9EPAu/hUy3DaOk+NXW/nZnlV4FL+hiity82oVqInX/TQvD5SA7d5WbxvvpYcBlCdY19BGqt2pzH1Y8B6BptfpYw1duxJE4eJ2MghvM7faSnScx48m9/FYgkv7fzGqwSWGtvi2+Q8zPPL1x53iB3lFQrdykFOoHEug38= dali@archlinux |
-- The CXX compiler identification is GNU 10.1.0 | |
-- The Fortran compiler identification is GNU 10.1.0 | |
-- Check for working CXX compiler: /usr/bin/g++ | |
-- Check for working CXX compiler: /usr/bin/g++ - works | |
-- Detecting CXX compiler ABI info | |
-- Detecting CXX compiler ABI info - done | |
-- Detecting CXX compile features | |
-- Detecting CXX compile features - done | |
-- Check for working Fortran compiler: /usr/bin/gfortran |
Let's say you have a text string that greets a person, 'Hello, Mark!'
.
If you write a program for this greeting you might want to compose the string for any name of the person.
One way to do this is to have a template string, 'Hello, ${user_name}!'
and then use a function that will
replace the ${...}
with value of variable user_name
. This is usually called string interpolation.
We want to have a dict interpolation, where the same is done for a nested structure.
For example, if you have a dictionary, {'user':'User_id${uid}'}
, and a variable uid=1
, we want to get