038 - July 14, 2019

A fun case of Rust to Rust FFI


This past week I worked on our continuous deployment.

I made some good progress and planning to finish things up this week.

Continuous Deployment of the Game's Web Client

The game's web client deployment consists of three files.

A .html file, a .wasm file, and a .js file.

The wasm file and JS file are generated by wasm-bindgen during our build process.

The HTML file looks like this:

<!-- HTML for Akigi Web Game Client -->

    <body style='margin: 0; padding: 0; width: 100%; height: 100%;'>
        <div id='akigi-web-client' style='width: 100%; height: 100%;'>
            <canvas id='akigi-game-canvas' width='900' height='560'></canvas>
        <script src='/web_client.js'></script>

            function start () {
                const { WebClient } = window.wasm_bindgen
                const rust = new WebClient()

            function downloadBytes(path, callback) {
                  .then(response => response.arrayBuffer())
                    .then(bytes => {
                        bytes = new Uint8Array(bytes)

We have a CI job for deploying the game's web client which ends up running the following:

set -e

ak dist download-game-server --name="current-prod" -o /tmp
ak test game-server-integration --server-staticlib /tmp/libgame_server.a
ak deploy web-client --name="latest-green-master"

We first download a static library binary of the game server that is currently running in production.

We then run our integration tests against it. If they pass we know that the latest client code is compatible with the live server.

Then, if those tests passed, we deploy the web client by copying the HTML, Wasm and JS into our public-acl s3 bucket.

Deploy process image Web client automatically deployed if latest integration tests pass against a staticlib of the server that is currently in production.

Next Week

We can't automatically deploy the game server because at any point there can be players connected to it via websocket.

So we need to explicitly decide to deploy it.

I've started working on a process that will allow me to deploy the game server.

The final CLI command should end up looking something like ak deploy-game-client --shutdown-timer 30, which would mean that the gave will get updated in 30 minutes and connected players will see a countdown indicating this.

More on that next week!

Cya next time!