knqyf263 / go-plugin

Go Plugin System over WebAssembly
MIT License
586 stars 30 forks source link

Able to configure Runtime and ModuleConfig for plugin #28

Closed dmvolod closed 1 year ago

dmvolod commented 1 year ago

Issue #, if available: fixes #21

Description of changes: This PR allows to provide custom options for following configurations during plugin initialization

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

dmvolod commented 1 year ago

main thing here is that the runtime allocated by NewRuntime should be closed on plugin.Close. This prevents resources leaks which would be more obvious later. This implies adding a field for it that defaults to nil (so that it is lazy allocated).

func (p *GreeterPlugin) Close(ctx context.Context) (err error) {
  return
}

Yes, good point, thanks. As we create runtime for each plugin load, seems to multiple runtime should be kept and closed. Current approach implemented, please review.

codefromthecrypt commented 1 year ago

@dmvolod I think this change should happen, so will pick up where you left off. Sorry things didn't work out but thanks for all your feedback and help!