Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid loading unused internal plugins #949

Open
wants to merge 1 commit into
base: rc/v5.0
Choose a base branch
from

Conversation

taclane
Copy link
Contributor

@taclane taclane commented Apr 19, 2024

The four "internal" plugins [openmhz_uploader, broadcastify_uploader, stat_socket, unit_script] are always loaded, whether or not the user intends to use them in their trunk-recorder installation.

After the configuration file is parsed, this PR checks if any of the mandatory configuration keys for the above plugins are present before adding them to the load list. This will reduce unnecessary API calls, and avoid the overhead of loading a plugin in duplicate should the user consolidate the configuration into the "plugins" section as shown in the example below:

    "plugins": [
        {
            "name": "Broadcastify",
            "library": "libbroadcastify_uploader.so",
            "enabled": true,
            "broadcastifyCallsServer": "https://api.broadcastify.com/call-upload",
            "broadcastifySslVerifyDisable": false,
            "systems": [
                {
                    "shortName": "sys1",
                    "broadcastifySystemId": 1234,
                    "broadcastifyApiKey": "api-key-vrry-secret"
                },
                {
                    "shortName": "sys2",
                    "broadcastifySystemId": 1235,
                    "broadcastifyApiKey": "api-key-vrry-secret"
                }
            ]
        }
    ]

"Internal" plugins (other than stat_socket) can be loaded in "plugin" section if desired. Aside from the convenience of managing a plugin's configuration in a single part of the config file, this also allows the user to toggle the enabled key to easily enable/disable a plugin as needed.

@taclane
Copy link
Contributor Author

taclane commented Apr 19, 2024

Openmhz and unit_script plugins also work when loaded in the "plugin" section instead; additional examples are below:

  "plugins": [
    {
      "name": "Openmhz",
      "library": "libopenmhz_uploader.so",
      "enabled": true,
      "uploadServer": "https://api.openmhz.com",
      "systems": [
        {
          "shortName": "sys1",
          "openmhzSystemId": "my_openmhz_sys",
          "apiKey": "anotherveryverylongapikey"
        },
        {
          "shortName": "sys2",
          "openmhzSystemId": "my_openmhz_sys",
          "apiKey": "anotherveryverylongapikey"
        }
      ]
    },
    {
      "name": "Unit Scripts",
      "library": "unit_script.so",
      "enabled": true,
      "systems": [
        {
          "shortName": "sys1",
          "unitScript": "/trunk/unitscripts/sys1.sh"
        },
        {
          "shortName": "sys2",
          "unitScript": "/trunk/unitscripts/sys1.sh"
        }
      ]
    }
  ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant