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

New mechanism to tweak/query transport plugins via Admin API #2354

Merged
merged 2 commits into from
Oct 5, 2020

Conversation

lminiero
Copy link
Member

@lminiero lminiero commented Sep 7, 2020

This PR adds a new synchronous Admin API request, called query_transport, that allows you to communicate with a transport plugin, like for instance query_eventhandler and query_logger already did for event handlers and loggers. The idea was to allow both dynamic configurations of transports (e.g., change settings) and queries on their internal state, where applicable. As with the other plugin categories that already supported something like this, it's an optional callback, meaning that your custom transport doesn't need to implement it: you'll need to recompile it, though, since the transport plugin API version has been bumped.

At the moment only very simple requests have been implemented: specifically, all transport plugins allow you to change the value of events and json you specified in the configuration files on the fly; the WebSocket transport also allows you to change the libwebsockets logging level; finally, some plugins also allow you to query the number of active connections (e.g., HTTP, WS, Unix Sockets). That's because this PR is, again, just opening the door to this new mechanism, and I didn't want to overdo it: I'm sure in the future we can add more meaningful tweaks, but for the time being everything else seemed to be more complex that this effort called for, so I went for the low hanging fruit instead.

For a couple of examples, this is the request you can send to the HTTP transport to get the number of active connections and the number of messages currently being served, and the response sent back by Janus:

curl -d '{"janus": "query_transport", "transaction": "123", "admin_secret": "janusoverlord", "transport": "janus.transport.http", "request": {"request": "connections"}}' http://localhost:7088/admin

{
   "janus": "success",
   "transaction": "123",
   "response": {
      "result": 200,
      "connections": {
         "http": 6,
         "admin_http": 1
      },
      "messages": 2
   }
}

while this is how you can change some of the settings (notice how the transport adds a note to say it handled the request, but won't be used since event handlers are globally disabled):

curl -d '{"janus": "query_transport", "transaction": "123", "admin_secret": "janusoverlord", "transport": "janus.transport.http", "request": {"request": "configure", "events": true}}' http://localhost:7088/admin

{
   "janus": "success",
   "transaction": "123",
   "response": {
      "result": 200,
      "notes": [
         "Event handlers disabled at the core level"
      ]
   }
}

Planning to merge soon, so feedback welcome.

@lminiero
Copy link
Member Author

lminiero commented Oct 5, 2020

Merging.

@lminiero lminiero merged commit ca84295 into master Oct 5, 2020
@lminiero lminiero deleted the query-transports branch October 5, 2020 09:49
PauKerr pushed a commit to caffeinetv/janus-gateway that referenced this pull request Nov 11, 2020
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