Dobby
3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
|
Public Types | |
enum | BusType { SessionBus , SystemBus } |
Public Member Functions | |
IpcService (BusType busType, const std::string &serviceName, int defaultTimeoutMs=-1) | |
IpcService (const std::string &dbusAddress, const std::string &serviceName, int defaultTimeoutMs=-1) | |
virtual bool | isValid () const override |
Returns true if we initialised ourselves successfully. More... | |
virtual std::shared_ptr< AI_IPC::IAsyncReplyGetter > | invokeMethod (const AI_IPC::Method &method, const AI_IPC::VariantList &args, int timeoutMs=-1) override |
Invoke a method and get reply asynchronously. More... | |
virtual bool | invokeMethod (const AI_IPC::Method &method, const AI_IPC::VariantList &args, AI_IPC::VariantList &replyArgs, int timeoutMs=-1) override |
Invoke a method and get reply synchronously. More... | |
virtual bool | emitSignal (const AI_IPC::Signal &signal, const AI_IPC::VariantList &args) override |
Emit a signal. More... | |
virtual std::string | registerMethodHandler (const AI_IPC::Method &method, const AI_IPC::MethodHandler &handler) override |
Register a method handler. More... | |
virtual std::string | registerSignalHandler (const AI_IPC::Signal &signal, const AI_IPC::SignalHandler &handler) override |
Register a signal handler. More... | |
virtual bool | unregisterHandler (const std::string ®Id) override |
Unregister a method or signal handler. More... | |
virtual bool | enableMonitor (const std::set< std::string > &matchRules, const AI_IPC::MonitorHandler &handler) override |
Enables monitor mode on the IPC service, this will effectively disable all registered method and signal handlers. More... | |
virtual bool | disableMonitor () override |
Disables monitor mode and restores normal behaviour. More... | |
virtual void | flush () override |
Flushes all messages out. More... | |
virtual bool | start () override |
Start IPC service. More... | |
virtual bool | stop () override |
Stop IPC service. More... | |
bool | isRegisteredObjectPath (const std::string &path) |
virtual bool | isServiceAvailable (const std::string &serviceName) const override |
Checks if the named service is available on the bus. More... | |
std::string | getBusAddress () const override |
Returns the dbus address the service is using. More... | |
Private Member Functions | |
bool | invokeMethodAndGetReply (DBusMessage *dbusSendMsg, AI_IPC::VariantList &replyArgs) |
DBusHandlerResult | handleDbusMessageCb (DBusMessage *message) |
DBusHandlerResult | handleDbusMessage (DBusMessage *message) |
DBusHandlerResult | handleDbusSignal (const AI_IPC::Signal &signal, const AI_IPC::VariantList &argList) |
DBusHandlerResult | handleDbusMethodCall (const AI_IPC::Method &method, const AI_IPC::VariantList &argList, DBusMessage *message) |
void | unregisterHandlers () |
void | registerObjectPath (const std::string &path) |
void | unregisterObjectPath (const std::string &path) |
bool | isDbusMessageAllowed (const std::string &sender, const std::string &interface) |
DBusHandlerResult | handleDbusMonitorEvent (DBusMessage *dbusMsg) |
Private Attributes | |
std::string | mServiceName |
std::string | mBusAddress |
std::shared_ptr< AI_IPC::DbusConnection > | mDbusConnection |
std::map< std::string, int > | mObjectPaths |
std::map< std::string, std::pair< AI_IPC::Method, AI_IPC::MethodHandler > > | mMethodHandlers |
std::map< std::string, std::pair< AI_IPC::Signal, AI_IPC::SignalHandler > > | mSignalHandlers |
AICommon::ThreadedDispatcher | mHandlerDispatcher |
std::mutex | mMutex |
std::atomic< bool > | mRunning |
int | mNextSignalHandlerRegId |
const int | mDefaultTimeoutMs |
bool | mValid |
std::atomic< bool > | mInMonitorMode |
AI_IPC::MonitorHandler | mMonitorCb |
std::set< std::string > | mMonitorMatchRules |
|
overridevirtual |
Disables monitor mode and restores normal behaviour.
It's recommended that flush() is called after this function to ensure that the monitor callback will no longer be called.
Implements AI_IPC::IIpcService.
|
overridevirtual |
Emit a signal.
@parameter[in] signal Signal definition @parameter[in] args Signal arguments/data
Implements AI_IPC::IIpcService.
|
overridevirtual |
Enables monitor mode on the IPC service, this will effectively disable all registered method and signal handlers.
This function is for debugging only, it can be used to monitor the entire bus and the interactions between clients.
For production builds this function always returns false.
Implements AI_IPC::IIpcService.
|
overridevirtual |
Flushes all messages out.
This method ensures that any message or signal handlers queued before this function was called are processed before the function returns.
For obvious reasons do not hold any lock that a handler might need while calling this function.
Implements AI_IPC::IIpcService.
|
overridevirtual |
Returns the dbus address the service is using.
Note the address is formatted like a dbus address and is NOT just the path to the unix socket.
Implements AI_IPC::IIpcService.
|
overridevirtual |
Invoke a method and get reply synchronously.
@parameter[in] method Method definition @parameter[in] args Method arguments @parameter[in] replyArgs Reply return by the method call @parameter[in] timeoutMs Timeout in milliseconds, -1 for default (30 seconds)
Implements AI_IPC::IIpcService.
|
overridevirtual |
Invoke a method and get reply asynchronously.
@parameter[in] method Method definition @parameter[in] args Method arguments @parameter[in] timeoutMs Timeout in milliseconds, -1 for default (30 seconds)
Implements AI_IPC::IIpcService.
|
overridevirtual |
Checks if the named service is available on the bus.
This method is expected to be used at start to determine if the daemons are up and running.
The method doesn't wait for the service to arrive, that would be nice to have and could be done by looking for the signals dbus send when a new client arrives. We could add that in the future rather than having this polling interface.
[in] | serviceName | The name of the service to check for. |
Implements AI_IPC::IIpcService.
|
overridevirtual |
Returns true if we initialised ourselves successfully.
Implements AI_IPC::IIpcService.
|
overridevirtual |
Register a method handler.
@parameter[in] method Method definition @parameter[in] handler Method handler
Implements AI_IPC::IIpcService.
|
overridevirtual |
Register a signal handler.
@parameter[in] method Signal definition @parameter[in] handler Signal handler
Implements AI_IPC::IIpcService.
|
overridevirtual |
Start IPC service.
It needs to be invoked to start the event dispatcher, which is required to handle method and signals, as well as to get method call reply.
Implements AI_IPC::IIpcService.
|
overridevirtual |
Stop IPC service.
The event dispatcher thread will be terminated.
Implements AI_IPC::IIpcService.
|
overridevirtual |
Unregister a method or signal handler.
@parameter[in] regId Registration Id
Implements AI_IPC::IIpcService.