Skip to content

Expose interfaces for introspection #12

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

GaikwadPratik
Copy link

This extends @knightpp's idea and actually exposes interfaces for introspection when server is running.

Related to #8 and #9

When a server is running, make service interace introspectable. This would help clients which are not generated from this library to invoke methods
@GaikwadPratik
Copy link
Author

@amenzhinsky,

Hope you had nice weekend...

any thoughts on PR?

@amenzhinsky
Copy link
Owner

Hi @GaikwadPratik, sorry for the late response.

Thanks I really did :)

I don't quite understand the need of the feature, can you give an example?

@GaikwadPratik
Copy link
Author

GaikwadPratik commented Apr 20, 2022

Hi @amenzhinsky,

I believe you are familiar with dbus-inspect.

In the attached video, first half is WITHOUT the PR while the second is WITH the PR.

Screencast.from.04-20-2022.07-03-07.AM.mp4

Basically, I'm writing a dbus-service(server instance) in Golang. When another developer wants to interact with the service, they WILL NOT know the interface(s) definition unless

  1. they look at source code OR
  2. perform Introspection on service at object path OR
  3. I will have to hardcode interface in the source code as shown here. I prefer to keep xml separate from code.

As shown in the above video, introspection returns nothing without the changes in PR.

@GaikwadPratik
Copy link
Author

@amenzhinsky ,

I hope above video and explanation was sufficient. Basic answer is that you won't be able to introspect and by extension call dbus server unless you know the api correctly from somewhere. I can't explain or provide any example simple than this.

P.S. I apologize for high resolution of the video. It would be better if you download it and then view it.

GaikwadPratik added a commit to GaikwadPratik/dbus-codegen-go that referenced this pull request Apr 23, 2022
replacing paths to own repo till amenzhinsky#12 is merged. Using replace directive in mod file is tedious because this will be indirect import and will vanish with every tidyness on mod. If and when amenzhinsky#12 is merged, this branch will be removed and original repo will be imported again. This branch helps exporting service to dbus for introspection
@amenzhinsky
Copy link
Owner

So, to generate server-side code you already have an introspection xml file, you can export org.freedesktop.DBus.Introspectable.Introspect that has only one method Introspect() string which can return its content.

@GaikwadPratik
Copy link
Author

GaikwadPratik commented Apr 27, 2022

@amenzhinsky ,

That didn't help. Please see attached video.

introspection.mp4

The example in above video is from clien_server. Perhaps you can directly update that.

P.S. please point out if I am doing any mistake in the above video

@amenzhinsky
Copy link
Owner

You need to do something like this:

conn.ExportMethodTable(map[string]interface{}{
	"Introspect": func() string {
		return "your-xml-goes-here"
	},
}, "/org/example/Demo", "org.freedesktop.DBus.Introspectable.Introspect")

@GaikwadPratik
Copy link
Author

GaikwadPratik commented Apr 30, 2022

that's what this PR does. Just automatically instead of asking consumers to do it manually. Or am I missing something?

@maltegrosse
Copy link

maltegrosse commented Sep 16, 2022

would be great to see this PR merged....
@GaikwadPratik have you also considered in your PR the Unexport function?

@maltegrosse
Copy link

maltegrosse commented Sep 17, 2022

@GaikwadPratik adding
err := conn.Export(nil, path, "org.freedesktop.DBus.Introspectable") if err != nil { return err }
to the unexport method seems to work

By trying to access the properties, I get following error:
string "Object does not implement the interface 'org.freedesktop.DBus.Properties'"

@GaikwadPratik
Copy link
Author

@maltegrosse ,

err := conn.Export(nil, path, "org.freedesktop.DBus.Introspectable") if err != nil { return err }
to the unexport method seems to work

Though I am not sure why would we want to UnExport these, I'll try to work on it.

By trying to access the properties, I get following error:
string "Object does not implement the interface 'org.freedesktop.DBus.Properties'"

Last time I tried this, it worked. How are you trying to access it?

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.

3 participants