Skip to content

v0.2.2

Pre-release
Pre-release
Compare
Choose a tag to compare
@mostafa mostafa released this 10 Jan 00:53
· 1419 commits to main since this release
c87274a

There are two major changes to in this release:

  1. GatewayD now supports configuration parameters from environment variables. The list of environment variables are here and the order of precedence for configs are as follows:

    This will be the order of precedence for loading and applying config:
    
    1. Plugin default values.
    2. Plugin config file.
    3. Environment variables for plugins.
    4. Global default values.
    5. Environment variables for global config.
    6. Global config updated by plugins via `OnConfigLoaded` hooks.
    
    Plugins override the global configs and has the highest precedence overall.
    
  2. The introduction of new hooks for traffic control. Previously there were 3 traffic control hooks, now they are 5:

    hook type description
    OnTraffic Notification of incoming traffic from the client.
    OnTrafficFromClient Traffic is received from the client. This can terminate the connection.1️⃣
    OnTrafficToServer Traffic is sent to the database server.
    OnTrafficFromServer Traffic is received from the database server.
    OnTrafficToClient Traffic is sent to the client.

    1️⃣ As explained here, it is now possible to terminate the connection before the request even reaches the database server. To achieve this, the plugins needs to have the OnTrafficFromClient RPC endpoint and also expose the hook in their config. Then they can achieve connection termination by setting two variables in the return value of the RPC endpoint:

    return structpb.NewStruct(map[string]interface{}{
        "terminate": true,
        "response":  base64.StdEncoding.EncodeToString([]byte{'X', 0, 0, 0, 4}),
    })

    The terminate variable instructs the proxy to stop sending the received data (from client) to the server. The response variable will be sent back to the client, instead. If there is no response in the return value, the connection from the client will close abruptly.

The use case of the second change mentioned above is to let plugins stop requests from reaching the server, for example in a cache plugin scenario, the plugin should decide whether to return the cached value (of a query, which is the previous server's response) or let the message reach the server (and cache it afterwards). This is now possible using connection termination.

The rest are refactorings, cleanups and fixes.

What's Changed

  • Load env-vars for configs by @mostafa in #86
  • Cleanup interfaces by @mostafa in #94
  • Slight refactoring of the hook system plus adding termination logic by @mostafa in #96

Full Changelog: v0.2.1...v0.2.2