Displaying 4 results from an estimated 4 matches for "pluginerror".
2020 Apr 24
1
[PATCH nbdkit] golang: Pass Plugin and Connection by reference not value.
...+var size uint64
+var size_set = false
+
+func (p *DiskPlugin) Config(key string, value string) error {
+ if key == "size" {
+ var err error
+ size, err = strconv.ParseUint(value, 0, 64)
+ if err != nil {
+ return err
+ }
+ size_set = true
+ return nil
+ } else {
+ return nbdkit.PluginError{Errmsg: "unknown parameter"}
+ }
+}
+
+func (p *DiskPlugin) ConfigComplete() error {
+ if !size_set {
+ return nbdkit.PluginError{Errmsg: "size parameter is required"}
+ }
+ return nil
+}
+
+func (p *DiskPlugin) Open(readonly bool) (nbdkit.ConnectionInterface, error) {
+ // Ope...
2020 Apr 21
2
[PATCH nbdkit v2] Add the ability to write plugins in golang.
...lt;stdlib.h>
+
+#define NBDKIT_API_VERSION 2
+#include <nbdkit-plugin.h>
+#include "wrappers.h"
+*/
+import "C"
+
+import (
+ "fmt"
+ "syscall"
+ "unsafe"
+)
+
+// The plugin may raise errors by returning this struct (instead of nil).
+type PluginError struct {
+ Errmsg string // string (passed to nbdkit_error)
+ Errno syscall.Errno // errno (optional, use 0 if not available)
+}
+
+func (e PluginError) String() string {
+ if e.Errno != 0 {
+ return e.Errmsg
+ } else {
+ return fmt.Sprintf("%s (errno %d)", e.Errmsg, e.Errno)
+...
2020 Apr 21
0
Re: [PATCH nbdkit v2] Add the ability to write plugins in golang.
...;
var size uint64
var size_set = false
func (p TestPlugin) Config(key string, value string) error {
if key == "size" {
var err error
size, err = strconv.ParseUint(value, 0, 64)
if err != nil {
return err
}
size_set = true
return nil
} else {
return nbdkit.PluginError{Errmsg: "unknown parameter"}
}
}
func (p TestPlugin) ConfigComplete() error {
if !size_set {
>+ return nbdkit.PluginError{Errmsg: "size parameter is required"}
}
return nil
}
func (p TestPlugin) Open(readonly bool) (nbdkit.PluginConnectionInterface, error) {...
2020 Apr 23
2
Re: [PATCH nbdkit v2] Add the ability to write plugins in golang.
...lt;stdlib.h>
+
+#define NBDKIT_API_VERSION 2
+#include <nbdkit-plugin.h>
+#include "wrappers.h"
+*/
+import "C"
+
+import (
+ "fmt"
+ "syscall"
+ "unsafe"
+)
+
+// The plugin may raise errors by returning this struct (instead of nil).
+type PluginError struct {
+ Errmsg string // string (passed to nbdkit_error)
+ Errno syscall.Errno // errno (optional, use 0 if not available)
+}
+
+func (e PluginError) String() string {
+ if e.Errno != 0 {
+ return e.Errmsg
+ } else {
+ return fmt.Sprintf("%s (errno %d)", e.Errmsg, e.Errno)
+...