Skip to content

Commit

Permalink
set some instructions of Ex 3 as bonus
Browse files Browse the repository at this point in the history
  • Loading branch information
mdorier committed May 18, 2023
1 parent f575761 commit 9cf8be3
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 13 deletions.
25 changes: 21 additions & 4 deletions docs/source/tutorials/margo/03_ex3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,32 @@ pointer to a Yokan provider handle (:code:`yoken_provider_handle_t`),
which you can now use to set the corresponding field in the :code:`YP_args`
structure. You have successfully injected a Yokan dependency into the YP provider!

The rest of this exercise will be less directed. The goal is now to pass
this provider handle down to the dummy phonebook so that it can use
Yokan as an implementation of a key/value store instead of relying on
the :code:`phonebook.h` implementation. You should now be familiar
Bonus: continuing to wire YP with Yokan
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

At this point, you have learned what this exercise aimed for you to learn,
namely how to write a Bedrock module, a Bedrock configuration with multiple
providers, and how to manage dependencies in Bedrock configurations and
Bedrock modules.

This bonus section invites you to complete the dependency injection of
Yokan into YP. It is a lot more complicated and a lot less guided, hence
feel free to stop there and ignore this bonus section.

The goal is now to pass this Yokan provider handle down to the dummy phonebook
so that it can use Yokan as an implementation of a key/value store instead of
relying on the :code:`phonebook.h` implementation. You should now be familiar
enough with the code to make the necessary changes bellow without
too much guidance. Keep the
`API of Yokan <https://github.com/mochi-hpc/mochi-yokan/blob/main/include/yokan/database.h>`_
open in a web browser for reference.

|cbox| First, you will need to register a Yokan provider in your
tests (:code:`tests/test-admin.cpp` and :code:`tests/test-client.cpp`) and
make sure it manages at least one database by passing it an appropriate
configuration string. Here we are doing manually what Bedrock would normally do
from a JSON configuration file.

|cbox| To add and keep a reference to the Yokan provider handle in the :code:`YP_provider`
structure (in :code:`src/provider.h`), you will need to copy the provided
:code:`yokan_provider_handle_t` in :code:`YP_provider_register`, and free
Expand Down
39 changes: 30 additions & 9 deletions docs/source/tutorials/thallium/03_ex3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,6 @@ following in the field in the definition of our YP provider.
You can also use :code:`"my-yokan-provider"` instead of :code:`"yokan:123"`.
Now Bedrock should restart accepting your configuration.

|cbox| In :code:`src/ProviderImpl.hpp` add a :code:`const tl::provider_handle& yokan_ph`
argument to the constructor. Add a corresponding :code:`m_yokan_ph` field to
the class and assign the provided constructor argument to it.

|cbox| In :code:`include/YP/Provier.hpp`, add a :code:`const tl::provider_handle& yokan_ph`
argument to the two constructors. In :code:`src/Provider.cpp` change the signature
of the constructor accordingly as well as the call to the underlying
:code:`ProviderImpl` constructor.

|cbox| Edit :code:`src/BedrockModule.cpp` once again. This time we will look at the
:code:`registerProvider` function at the beginning of the file. Use the args
variable to find the dependency to Yokan as follows.
Expand All @@ -178,6 +169,36 @@ variable to find the dependency to Yokan as follows.
You will need to include :code:`yokan/provider-handle.h` to get the definition
of :code:`yk_provider_handle_t`.

You have now retrieved a Yokan provider handle pointing to your Yokan provider,
in the context of registering a YP provider.

Bonus: continuing to wire YP with Yokan
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

At this point, you have learned what this exercise aimed for you to learn,
namely how to write a Bedrock module, a Bedrock configuration with multiple
providers, and how to manage dependencies in Bedrock configurations and
Bedrock modules.

This bonus section invites you to complete the dependency injection of
Yokan into YP. It is a lot more complicated and a lot less guided, hence
feel free to stop there and ignore this bonus section.

|cbox| First, you will need to instanciate a :code:`yk::Provider` in your
tests (:code:`tests/AdminTest.cpp` and :code:`tests/PhonebookTest.cpp`) and
make sure it manages at least one database by passing it an appropriate
configuration string. Here we are doing manually what Bedrock would normally do
from a JSON configuration file.

|cbox| In :code:`src/ProviderImpl.hpp` add a :code:`const tl::provider_handle& yokan_ph`
argument to the constructor. Add a corresponding :code:`m_yokan_ph` field to
the class and assign the provided constructor argument to it.

|cbox| In :code:`include/YP/Provier.hpp`, add a :code:`const tl::provider_handle& yokan_ph`
argument to the two constructors. In :code:`src/Provider.cpp` change the signature
of the constructor accordingly as well as the call to the underlying
:code:`ProviderImpl` constructor.

|cbox| You can convert this :code:`yokan_ph` into a thallium provider handle as
follows before passing it to the :code:`Provider` constructor.

Expand Down

0 comments on commit 9cf8be3

Please sign in to comment.