Strumenta / starlasu-lionweb-repository-client

0 stars 0 forks source link

Initialize the DB #8

Closed alessiostalla closed 6 months ago

alessiostalla commented 6 months ago

During development, we connect to a freshly provisioned model repository pointing to an empty DB. In that scenario, we have to initialize the DB before using it:

    val url = "http://${client.hostname}:${client.port}/init"
    val request: Request = Request.Builder()
        .url(url)
        .post("".toRequestBody())
        .build()
    OkHttpClient().newCall(request).execute().use { response ->
        if (response.code == 200) {
            println("DB initialized")
        } else {
            println("DB initialization failed, HTTP ${response.code}: ${response.body?.string()}")
        }
    }

It would be useful if the client came with this built into a method one can call for testing, at least for now. Although ideally the model-repo should init itself at startup.

ftomassetti commented 6 months ago

I created an issue in the LionWeb repository: https://github.com/LionWeb-io/lionweb-repository/issues/31

ftomassetti commented 6 months ago

In the meantime, I will add this method, as requested