feat: add LoadReader method to generated funcs#72
feat: add LoadReader method to generated funcs#72darkliquid wants to merge 1 commit intoknqyf263:mainfrom
Conversation
When generating the plugin loading functions from protobufs, previously there was only an option to load plugins directly from disk via file names. This prevents use cases such as loading plugins embedded using `embed` or via an `fs.FS` virtual filesystem. To address this, there is now a `LoadReader` method generated that accepts an `io.Reader` and uses that via `io.ReadAll`, rather than having to load a file via `os.ReadFile` first. The existing `Load` method has been rewritten to simply call `LoadReader` with the result of calling the `os.Open` with the file name.
|
@knqyf263 thoughts on this PR? |
|
I haven't tested it myself, but if someone else has tested it and confirmed that it works, the change seems fine. |
Ok, let's keep it in PR, I'll do testing today. |
|
@knqyf263 Will this be added to the master? |
|
@darkliquid maybe keep
First two will call |
|
@darkliquid are you planning to make changes? |
|
I was not. I'd rather not bloat the PR with additional refactoring work. If we want to add wrappers around |
Issue #, if available:
#52 #53
Description of changes:
I ended up writing this for my own use before I noticed that there was an existing PR/Issue for this already. Since the other one still hasn't been merged, I figured I may as well throw my hat in the ring as well. By sheer coincidence it's almost identical to the other PR, except for the following:
LoadReaderinstead ofLoadFromBinaryos.ReadFileinLoadwithos.Openand pass the*os.FiletoLoadReader, can defer the*os.File.Close()mise use protocas of submitting this PRWhen generating the plugin loading functions from protobufs, previously there was only an option to load plugins directly from disk via file names. This prevents use cases such as loading plugins embedded using
embedor via anfs.FSvirtual filesystem.To address this, there is now a
LoadReadermethod generated that accepts anio.Readerand uses that viaio.ReadAll, rather than having to load a file viaos.ReadFilefirst. The existingLoadmethod has been rewritten to simply callLoadReaderwith the result of calling theos.Openwith the file name.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.