Dataflow¶
Bootup flow when the Barbican API service begins¶
This is the sequence of calls for booting up the Barbican API server:
bin/barbican.sh start
: Launches a WSGI service that performs a PasteDeploy process, invoking the middleware components found inbarbican/api/middleware
as configured inetc/barbican/barbican-api-paste
. The middleware components invoke and then execute the Pecan application created viabarbican/api/app.py:create_main_app()
, which also defines the controllers (defined inbarbican/api/controllers/
) used to process requested URI routes.
Typical flow when the Barbican API executes¶
For synchronous calls, the following sequence is generally followed:
- A client sends an HTTP REST request to the Barbican API server.
- The WSGI server and routing invokes a method on one of the
XxxxController
classes inbarbican/api/controllers/xxxx.py
, keyed to an HTTP verb (so one of POST, GET, DELETE, or PUT).- Example - GET /secrets:
- In
barbican/api/controllers/secrets.py
, theSecretController
‘son_get()
is invoked. - A
SecretRepo
repository class (found inbarbican/model/respositories.py
) is then used to retrieve the entity of interest, in this case as aSecret
entity defined inbarbican/model/models.py
. - The payload is decrypted as needed, via
barbican/plugin/resources.py
‘sget_secret()
function. - A response JSON is formed and returned to the client.
- In
- Example - GET /secrets:
For asynchronous calls, the following sequence is generally followed:
- A client sends an HTTP REST request to the Barbican API server.
- The WSGI server and routing again invokes a method on one of the
XxxxcController
classes inbarbican/api/controllers/
. - A remote procedure call (RPC) task is enqueue for later processing by a
worker node.
- Example - POST /orders:
- In
barbican/api/controllers/orders.py
, theOrdersController
‘son_post()
is invoked. - The
OrderRepo
repository class (found inbarbican/model/respositories.py
) is then used to create thebarbican/model/models.py
‘sOrder
entity in a ‘PENDING’ state. - The Queue API’s
process_type_order()
method on theTaskClient
class (found inbarbican/queue/client.py
) is invoked to send a message to the queue for asynchronous processing. - A response JSON is formed and returned to the client.
- In
- Example - POST /orders:
- The Queue service receives the message sent above, invoking a corresponding
method on
barbican/queue/server.py
‘sTasks
class. This method then invokes theprocess_and_suppress_exceptions()
method on one of thebarbican/tasks/resources.py
‘sBaseTask
implementors. This method can then utilize repository classes as needed to retrieve and update entities. It may also interface with third party systems via plugins`. Thebarbican/queue/client.py
‘sTaskClient
class above may also be invoked from a worker node for follow on asynchronous processing steps.- Example - POST /orders (continued):
- Continuing the example above, the queue would invoke the
process_type_order()
method onbarbican/queue/server.py
‘sTasks
class. Note the method is named the same as theTaskClient
method above by convention. - This method then invokes
process_and_suppress_exceptions()
on thebarbican/tasks/resources.py
‘sBeginTypeOrder
class. This class is responsible for processing all newly-POST-ed orders.
- Continuing the example above, the queue would invoke the
- Example - POST /orders (continued):