Skip to content

Commit

Permalink
Add binpath to config
Browse files Browse the repository at this point in the history
  • Loading branch information
Daan-Adrichem committed Aug 11, 2021
1 parent 9ba7721 commit 7bf86db
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ func main() {
LogCallback: func(s string) {
fmt.Println("[PDFIUM ERROR]: " + s)
},
SubprocessMain: "./subprocess",
Command: pdfium.Command{
BinPath: "go",
Args: []string{"run", "./subprocess"},
},
})
}
20 changes: 11 additions & 9 deletions pdfium/pdfium.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@ type worker struct {
var workerPool *pool.ObjectPool

type Config struct {
MinIdle int
MaxIdle int
MaxTotal int
LogCallback func(string)
SubprocessMain string
MinIdle int
MaxIdle int
MaxTotal int
LogCallback func(string)
Command Command
}

type Command struct {
BinPath string
Args []string
}

func InitLibrary(config Config) { // serve one thread that is "native" through cgo
Expand All @@ -56,13 +61,10 @@ func InitLibrary(config Config) { // serve one thread that is "native" through c
func(goctx.Context) (interface{}, error) {
newWorker := &worker{}

binPath := "go"
args := []string{"run", config.SubprocessMain}

client := plugin.NewClient(&plugin.ClientConfig{
HandshakeConfig: handshakeConfig,
Plugins: pluginMap,
Cmd: exec.Command(binPath, args...),
Cmd: exec.Command(config.Command.BinPath, config.Command.Args...),
Logger: logger,
})

Expand Down

0 comments on commit 7bf86db

Please sign in to comment.