We're going to be getting Conveyor working on top of Jussi. This will involve having Condenser, Jussi and Conveyor all running simultaneously on our dev machine.
Clone Jussi and apply this diff - this preps Jussi for local conveyor development:
git apply jussi_local_conveyor_config.diff
There is one environment specific edit that's not covered by this diff.
In PROD_UPSTREAM_CONFIG.json
, for the config:
["conveyor","http://192.168.11.3:8090"]
You need to specify an IP that is accessible on your dev computer's local networks, i.e. your wireless card's or docker vlan's address.
To discover this, in the terminal run ifconfig
, in the case of Docker's Vlan, the IP is identified at dockerO
under inet
, something like:
172.17.0.1
If you run conveyor with make devserver
it will default to port 8090
. Therefore in this example case we edit PROD_UPSTREAM_CONFIG.json
:
["conveyor","http://172.17.0.1:8090"]
Build Jussi's Docker Image - Takes a while.
docker build -t="$USER/jussi:$(git rev-parse --abbrev-ref HEAD)" .
docker run -itp 9000:8080 "$USER/jussi:$(git rev-parse --abbrev-ref HEAD)"
Because we are going to be running a bunch of things locally we map Docker's port 8080 to 9000.
Apply diff to condenser:
git apply condenser_local_conveyor_config.diff
SDC_DATABASE_URL="mysql://root@127.0.0.1/steemit_dev" NODE_ENV=development node ./node_modules/babel-cli/bin/babel-node.js ./webpack/dev-server.js
Conveyor uses the node-config
module, [per the load order] we can create a local.toml
config like so:
echo "admin_role = 'foobarman'
rpc_node = 'http://api.steemitstage.com/'" > config/local.toml
where foobarman
is some existing steem username that you have the private posting key for.
and the rpc_node
is the api for the steem blockchain we will be authenticating that user against.
make devserver
All being well, Jussi, Conveyor, and Condenser are all up and running locally. It's time to test out the feature-flags functionality we are interested in.
yarn global add rpcit
you can optionally specify default credentials for interacting with Steem RPC apis with:
export RPCIT_KEY=wif RPCIT_ACCOUNT=accountname
where 'wif' is a legitimate key, (in this example your user's private-posting-key, available at:
https://steemit.com/@accountname/permissions
- note the 'private' posting key needs to be toggled on to be displayed.
rpcit -a https://conveyor.steemitdev.com -s conveyor.set_feature_flag_probability testflag :0.5
This creates a feature flag called 'testflag' with a 50% probablity that it will resolve to true for a given user.
If you did not export the rpcit
globals in the above step you'll need to include credentials like this:
RPCIT_KEY=wif RPCIT_ACCOUNT=foobarman rpcit -a http://localhost:9000 -s conveyor.set_feature_flag_probability testflag :0.5
Navigate to the locally running instance of Condenser in your browser. The pertinent call to conveyor happens in the user saga. So to test we need to be a logged in user. As a logged in user refreshing the page should trigger a call from Condenser to get currently enabled feature flags from Conveyor (via Jussi). We can watch the Conveyor logs in the terminal to determine if this is happening.
--
rpc_req: {
"id": 554497485567665,
"method": "conveyor.get_feature_flags"
}
Now we can wrap front-end code in the <ConnectedFlag />
Higher-order-component to have it conditionally display depending on what the given flag resolves to. In the event that the flag resolves to false or if it is not found due to some error, a fallback component is rendered.
Demo usage:
// Conditionally render any number of wrapped Children
<ConnectedFlag
flag="testflag"
Fallback={<LoadingIndicator/>}
>
<h1> Hello World </h1>
</ConnectedFlag>
// Explicitly Render a singular component.
<ConnectedFlag
flag="testflag"
FlagComponent={<Icon name="user" />}
Fallback={<LoadingIndicator/>}
/>
// If flag is false or not present, render a fallback
<ConnectedFlag
flag="testflag"
FlagComponent={<Icon name="user" />}
Fallback={<LoadingIndicator/>}
/>
This can be tested by applying:
git apply condenser_demo.diff
and navigating to localhost:8080/faq.html
where 'Hello World' will appear whenever the flag named testflag
evaluates to true (50% of the time) and a loading indicator will appear when it does not.
It's not working properly with this configuration in local based on current Jussi repository
how to solve this issue?
steemit/jussi#216