Skip to content

Concepts

CLIENT FUNCTIONS

Special messaging service to build robust command control application

Apart from standard pub / sub and call / response messaging services, dataBridges designs and develops special purpose messaging services.

  • Client-functions is one such feature that helps dev.ops team to design and deploy a robust command control system.

What can you build using client functions?

  • Client-function also can be used by app developers to implement unique process where the server applications talks to a connected session (web, mobile, devices) directly.
  • for example say based on certain criteria, the server application would like a connected mobile app or browser session to connect to a URL and calculate latency and give back the information real-time. Both the apps (mobile, browser), exposes a client-function called latencyCheck and the server app can execute this function targeting specific sessions.
    • for all the connected mobile, browser session from IP-location = 'New-Brunswick, New-Jersey', execute client-function:latencyCheck [ input url 'us.east-api.mycompany-url.com'].

Lets build a simple command-control system

Lets take a look at a very simple command-control system

  • lets consider, the company has a set of system monitoring script to
- get machine information
- get installed software
- get installed security patch
- get current cpu, memory, disk.io
- get machine.load.avg

Now lets design a very simple command control system

control-monitoring server

  • This is a simple server program (use python, c# or node.js)
  • It has a list of machines (ipaddress_machinename), that will be managed by this command control system.
  • It exposes an RPC server called command.control with a single function authoriseSysChannel
  • This function expects machine-id = ip_machinename, databridges.session-id
  • If the ip_machinename is available as white-listed machine, the function will authorise and create a JWT for the session to connect to sys:commandControl Channel.
  • The server program also connects to channel sys:commandControl
  • The server will receive participant-joined and participant-left messages whenever a server connects or disconnects from dataBridges network.
  • This allows the server program to implement server ONLINE, OFFLINE monitoring system easily.

server-management script = manageMyServer.py

  • This python program wil be deployed as a service and will continuously run in background.

  • The script will expose the below client-function

- Machine-info
- sw-list
- installed-sec-patches
- Current-cpu-mem-diskIo
- Current-load
  • On script startup

  • extract the IP address and machine name and create machine.id = IPaddress_machineName

  • connect to dataBridges using app.key
  • connect to public rpc.server('command.control')
  • expose a function called access_token
    • Inside this function call command.control:authoriseSysChannel
    • pass machine.ID and session.ID
  • subscribe to channel sys:commandControl
    • When the channel is subscribed, the library will execute access_token function to get the JWT and pass the JWT along with the channel name to dataBridges router.
    • When the subscription is successful , the command control server will receive notification that IP_machineName has joined the network.
    • when the program disconnects or server shuts-down, the dataBridges network will send IP_machineName left message to the command control server.

Server management workbench scripts.

  • The devOPS team now has an infrastructure where they have servers that have exposed home grown management functions.
  • This allows the devOPS to write workbench scripts.
    • Workbench scripts are simple scripts that can be written using python, node.js, c# programming language (Python being most popular programming language for DevOps).
    • These script uses dataBridges server library and connects to channel sys:commandControl
    • On connecting to the channel sys:commandControl, the script will receive list of all the servers connected to the channel as participant-joined and the script can create a simple list:servers
    • For each servers in list:server
      • the script can execute any of the client_functions
      • for example, write a script to list out all servers whose load.average > 10

Here we saw how dataBridges client-functions and sys:channels allows us to design, deploy a robust command control system.