FAQ
Hello Gophers,

I have written a basic library for writing out-of-process plugins. It is
entirely programmatic and with a (hopefully) simple API.

Pingo: https://github.com/dullgiulio/pingo

It's currently no more than the basics: starting the subprocess, connecting
(tcp or unix socket) and then the interface is basically the same as
standard RPC (which it uses internally).

Although there are projects out there doing exactly this, I couldn't find a
stand alone library, so I wrote one.

Any feedback/pull-requests appreciated!

Thank you!

--
Giulio Iotti
https://twitter.com/dullboy

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Tamás Gulácsi at Apr 27, 2015 at 2:04 pm
    I've found that using stdin and stdout for communication with the subprocess works, so no port/path/namespace management is needed.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Tamás Gulácsi at Apr 27, 2015 at 7:38 pm

    2015. április 27., hétfő 16:03:55 UTC+2 időpontban Tamás Gulácsi a
    következőt írta:
    I've found that using stdin and stdout for communication with the
    subprocess works, so no port/path/namespace management is needed.

    Just to elaborate, I'm doing: http://play.golang.org/p/YolFEbU2dS

    TL;DR: server (plugin):
    s := rpc.NewServer()
    s.RegisterName("Hook", pluginRPCWrap{rcvr})
    s.ServeConn(struct {
    io.Reader
    io.Writer
    io.Closer
    }{os.Stdin, os.Stdout,
    multiCloser{[]io.Closer{os.Stdout, os.Stdin, procCloser{}}},
    })

    master process:
    in, err := cmd.StdinPipe()
    out, err := cmd.StdoutPipe()
    cmd.Stderr = os.Stderr
    if err := cmd.Start(); err != nil {
    return nil, err
    }
    pc := procCloser{cmd.Process}
    return rpc.NewClient(struct {
    io.Reader
    io.Writer
    io.Closer
    }{out, in, multiCloser{[]io.Closer{in, out, pc}}}), nil

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Marc-Antoine Ruel at May 9, 2015 at 5:47 pm

    2015-04-27 10:03 GMT-04:00 Tamás Gulácsi <tgulacsi78@gmail.com>:

    I've found that using stdin and stdout for communication with the
    subprocess works, so no port/path/namespace management is needed.
    That's what I've been doing too and I pass fatal errors over stderr; which
    fits well since it's what happens when panic() is executed.


    2015-04-27 11:34 GMT-04:00 Haddock <ffm2002@web.de>:
    This is some cool stuff, Giulio. Have you thought of adding some user
    specifyable version number so that the server could detect version mismatch?
    For interface versioning I made a quick hack (
    https://github.com/maruel/interfaceGUID) that calculates a digest from an
    interface. When the plugin starts, it prints the digest, and the server
    accepts it only if it matches, otherwise it rebuilds the plugin and tries
    again.

    M-A

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Minux at May 10, 2015 at 1:51 am

    On Sat, May 9, 2015 at 1:46 PM, Marc-Antoine Ruel wrote:

    For interface versioning I made a quick hack (
    https://github.com/maruel/interfaceGUID) that calculates a digest from an
    interface. When the plugin starts, it prints the digest, and the server
    accepts it only if it matches, otherwise it rebuilds the plugin and tries
    again.
    It doesn't handle recursive types correctly.
    For example,

    type T *T
    interfaceGUID.CalculateGUID(reflect.TypeOf(T(nil)))

    will hang (http://play.golang.org/p/aXbhPi0F-L) until reaching the
    maximum goroutine stack.

    also the function names is a bit long and repeats the package name.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Marc-Antoine Ruel at May 10, 2015 at 3:15 pm
    Thanks for the comment! Fixed both issues with
    https://github.com/maruel/interfaceGUID/commit/043c81a39b4cfb77547164a46fcb6dc5d93db852
    .

    M-A

    2015-05-09 21:50 GMT-04:00 minux <minux@golang.org>:
    On Sat, May 9, 2015 at 1:46 PM, Marc-Antoine Ruel wrote:

    For interface versioning I made a quick hack (
    https://github.com/maruel/interfaceGUID) that calculates a digest from
    an interface. When the plugin starts, it prints the digest, and the server
    accepts it only if it matches, otherwise it rebuilds the plugin and tries
    again.
    It doesn't handle recursive types correctly.
    For example,

    type T *T
    interfaceGUID.CalculateGUID(reflect.TypeOf(T(nil)))

    will hang (http://play.golang.org/p/aXbhPi0F-L) until reaching the
    maximum goroutine stack.

    also the function names is a bit long and repeats the package name.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Haddock at Apr 27, 2015 at 4:30 pm
    This is some cool stuff, Giulio. Have you thought of adding some user
    specifyable version number so that the server could detect version mismatch?

    Cheers, Oliver

    Am Montag, 27. April 2015 15:15:09 UTC+2 schrieb Giulio Iotti:
    Hello Gophers,

    I have written a basic library for writing out-of-process plugins. It is
    entirely programmatic and with a (hopefully) simple API.

    Pingo: https://github.com/dullgiulio/pingo

    It's currently no more than the basics: starting the subprocess,
    connecting (tcp or unix socket) and then the interface is basically the
    same as standard RPC (which it uses internally).

    Although there are projects out there doing exactly this, I couldn't find
    a stand alone library, so I wrote one.

    Any feedback/pull-requests appreciated!

    Thank you!

    --
    Giulio Iotti
    https://twitter.com/dullboy
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Bronze man at May 10, 2015 at 11:25 am
    Thanks.
    A very good idea.
    If I can call it from java or objective-c, It may be a good start point to
    develop a mobile cross platform app.
    On Monday, April 27, 2015 at 9:15:09 PM UTC+8, Giulio Iotti wrote:

    Hello Gophers,

    I have written a basic library for writing out-of-process plugins. It is
    entirely programmatic and with a (hopefully) simple API.

    Pingo: https://github.com/dullgiulio/pingo

    It's currently no more than the basics: starting the subprocess,
    connecting (tcp or unix socket) and then the interface is basically the
    same as standard RPC (which it uses internally).

    Although there are projects out there doing exactly this, I couldn't find
    a stand alone library, so I wrote one.

    Any feedback/pull-requests appreciated!

    Thank you!

    --
    Giulio Iotti
    https://twitter.com/dullboy
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedApr 27, '15 at 1:15p
activeMay 10, '15 at 3:15p
posts8
users6
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase