Dobby  3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
Public Types | Public Member Functions | List of all members
IDobbyIPCUtils Class Referenceabstract
Inheritance diagram for IDobbyIPCUtils:
Inheritance graph
[legend]

Public Types

enum class  BusType { NoneBus , SystemBus , AIPrivateBus , AIPublicBus }
 The type of dbus to call methods on / emit signals.
 

Public Member Functions

virtual std::shared_ptr< AI_IPC::IAsyncReplyGetteripcInvokeMethod (const BusType &bus, const AI_IPC::Method &method, const AI_IPC::VariantList &args, int timeoutMs=-1) const =0
 Wrappers around the IPC services in the Dobby daemon. More...
 
virtual bool ipcInvokeMethod (const BusType &bus, const AI_IPC::Method &method, const AI_IPC::VariantList &args, AI_IPC::VariantList &replyArgs) const =0
 Invokes the ipc method. More...
 
virtual bool ipcEmitSignal (const BusType &bus, const AI_IPC::Signal &signal, const AI_IPC::VariantList &args) const =0
 Sends out a signal over dbus. More...
 
virtual bool ipcServiceAvailable (const BusType &bus, const std::string &serviceName) const =0
 Queries if the given service is available on the bus. More...
 
virtual int ipcRegisterServiceHandler (const BusType &bus, const std::string &serviceName, const std::function< void(bool)> &handlerFunc)=0
 Registers a callback function that will be called when the given service is added or removed from the bus. More...
 
virtual int ipcRegisterSignalHandler (const BusType &bus, const AI_IPC::Signal &signal, const AI_IPC::SignalHandler &handlerFunc)=0
 Registers a callback function that will be called when the given signal is received on the bus. More...
 
virtual void ipcUnregisterHandler (const BusType &bus, int handlerId)=0
 Unregisters either a service or signal handler. More...
 
virtual std::string ipcDbusAddress (const BusType &bus) const =0
 Returns complete address to the dbus daemon. More...
 
virtual std::string ipcDbusSocketPath (const BusType &bus) const =0
 Returns just the path to the socket for the dbus daemon. More...
 

Member Function Documentation

◆ ipcDbusAddress()

virtual std::string IDobbyIPCUtils::ipcDbusAddress ( const BusType bus) const
pure virtual

Returns complete address to the dbus daemon.

Parameters
[in]busThe bus to get the socket path for.
Returns
the path to the socket, or an empty string if no socket is available.

Implemented in DobbyIPCUtils.

◆ ipcDbusSocketPath()

virtual std::string IDobbyIPCUtils::ipcDbusSocketPath ( const BusType bus) const
pure virtual

Returns just the path to the socket for the dbus daemon.

Parameters
[in]busThe bus to get the socket path for.
Returns
the path to the socket, or an empty string if no socket is available.

Implemented in DobbyIPCUtils.

◆ ipcEmitSignal()

virtual bool IDobbyIPCUtils::ipcEmitSignal ( const BusType bus,
const AI_IPC::Signal signal,
const AI_IPC::VariantList &  args 
) const
pure virtual

Sends out a signal over dbus.

This is a pure wrapper around the IpcService::emitSignal function.

Parameters
[in]busThe bus to emit the signal on.
[in]signalThe signal details.
[in]argsThe signal args.
Returns
true if successful, otherwise false.

Implemented in DobbyIPCUtils.

◆ ipcInvokeMethod() [1/2]

virtual bool IDobbyIPCUtils::ipcInvokeMethod ( const BusType bus,
const AI_IPC::Method method,
const AI_IPC::VariantList &  args,
AI_IPC::VariantList &  replyArgs 
) const
pure virtual

Invokes the ipc method.

This is a pure wrapper around the IpcService::invokeMethod function.

Parameters
[in]busThe bus call the method on.
[in]methodThe method to call.
[in]argsThe method args
[out]replyArgsThe reply.
Returns
true if successful, otherwise false.

Implemented in DobbyIPCUtils.

◆ ipcInvokeMethod() [2/2]

virtual std::shared_ptr<AI_IPC::IAsyncReplyGetter> IDobbyIPCUtils::ipcInvokeMethod ( const BusType bus,
const AI_IPC::Method method,
const AI_IPC::VariantList &  args,
int  timeoutMs = -1 
) const
pure virtual

Wrappers around the IPC services in the Dobby daemon.

We provide these as wrappers so that hooks don't have to spin up their own connections to a particular bus, instead they can use the service threads already created inside the Dobby daemon.

TODO: flesh out a bit more

Implemented in DobbyIPCUtils.

◆ ipcRegisterServiceHandler()

virtual int IDobbyIPCUtils::ipcRegisterServiceHandler ( const BusType bus,
const std::string &  serviceName,
const std::function< void(bool)> &  handlerFunc 
)
pure virtual

Registers a callback function that will be called when the given service is added or removed from the bus.

This in turn is useful for hooks to manage situations where the daemon they are talking to has crashed / restarted.

Case in point is the Jumper hook, it wants to know if the daemon has crashed so it doesn't block container startup by trying to talk to a nonexisting daemon. And likewise it wants to know when it's arrived back so it can re-create any state stored in the daemon.

To remove the handler call ipcUnregisterHandler with the handler id returned by this function.

Parameters
[in]busThe bus to watch the service on.
[in]serviceNameThe name of the service to look out for.
[in]handlerFuncCallback function called when the service is added or removed. If added the argument supplied will be true, if removed it will be false.
Returns
if the notifier is successifully added then a positive handler id will be returned, otherwise -1

Implemented in DobbyIPCUtils.

◆ ipcRegisterSignalHandler()

virtual int IDobbyIPCUtils::ipcRegisterSignalHandler ( const BusType bus,
const AI_IPC::Signal signal,
const AI_IPC::SignalHandler &  handlerFunc 
)
pure virtual

Registers a callback function that will be called when the given signal is received on the bus.

This is a pure wrapper around the IpcService.registerSignalHandler function.

Parameters
[in]busThe bus to watch for the signal on.
[in]signalThe signal details to watch for.
[in]handlerFuncCallback function called when the signal is received.
Returns
if the handler is successifully added then a positive handler id will be returned, otherwise -1

Implemented in DobbyIPCUtils.

◆ ipcServiceAvailable()

virtual bool IDobbyIPCUtils::ipcServiceAvailable ( const BusType bus,
const std::string &  serviceName 
) const
pure virtual

Queries if the given service is available on the bus.

This is a pure wrapper around the IpcService::serviceAvailable function.

Parameters
[in]busThe bus to check.
[in]serviceNameThe service to query.
Returns
true if the service is available, otherwise false.

Implemented in DobbyIPCUtils.

◆ ipcUnregisterHandler()

virtual void IDobbyIPCUtils::ipcUnregisterHandler ( const BusType bus,
int  handlerId 
)
pure virtual

Unregisters either a service or signal handler.

Parameters
[in]busThe bus to remove the handler for.
[in]handlerIdThe integer handler id returned by the register function.

Implemented in DobbyIPCUtils.


The documentation for this class was generated from the following file: