search for: connectioninterfac

Displaying 3 results from an estimated 3 matches for "connectioninterfac".

Did you mean: connectioninterface
2020 Apr 24
1
[PATCH nbdkit] golang: Pass Plugin and Connection by reference not value.
...called when the client has connected and where you should return a new instance of your connection struct. For example: - func (p MyPlugin) Load() { + func (p *MyPlugin) Load() { // global callback used for initializing the plugin } - func (p MyPlugin) Open(readonly bool) (nbdkit.ConnectionInterface, error) { + func (p *MyPlugin) Open(readonly bool) (nbdkit.ConnectionInterface, error) { // new client has connected return &MyConnection{}, nil } - func (c MyConnection) GetSize() (uint64, error) { + func (c *MyConnection) GetSize() (uint64, error) { // call...
2020 Apr 23
2
Re: [PATCH nbdkit v2] Add the ability to write plugins in golang.
...(e PluginError) Error() string { + return e.String() +} + +// The plugin interface. +type PluginInterface interface { + // Open is required for all plugins. + // Other methods are optional. + Load() + Unload() + Config(key string, value string) error + ConfigComplete() error + Open(readonly bool) (ConnectionInterface, error) +} + +// The client connection interface. +type ConnectionInterface interface { + // GetSize and PRead are required for all plugins. + // Other methods are optional. + Close() + GetSize() (uint64, error) + PRead(buf []byte, offset uint64, flags uint32) error +} + +// Default implementation...
2020 Apr 21
2
[PATCH nbdkit v2] Add the ability to write plugins in golang.
Thanks: Dan Berrangé XXX UNFINISHED: - Is using uintptr for the handle a good idea? Plugins must return something != 0. In other languages we would allow plugins to return an arbitrary object here, but this is not possible in golang because of lack of GC roots. - Default can_* methods are hard to implement. Ideally we would be able to test if a user plugin implements a