Skip to content

EIP: calling user defined functions from SDK host #5

@nilslice

Description

@nilslice

Say a user uses the Go SDK and wants to "share" a Go function from their app to a plugin, making it an import to said plugin.

func logMessage(msg string) {
  log.Println("from plugin:", msg)
}

func main() {
  ext := extism.New()
  plugin := ext.LoadPlugin(...)

  // provide a handle to the function, adding some detail about 
  // what function to call, the "namespace" (module namespace 
  // to import from in wasm), the function name within wasm, and 
  // its params/returns
  plugin.AddFunc(logMessage, "AcmeAppLib", "log",  ...params) // tbd, how to declare the params/returns here



  out, err := plugin.Call(...)
  // ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions