hashicorp / hashicorp/go-plugin

Plain English Protocol Documentation

Open
#27 16 comments 1 reaction 0 assignees View on GitHub
Dominant language
Go
Stars
6.1k
Forks
511
Avg merge
22h 47m
Merged PRs (30d)
4

Description

I might be missing some detail, but I'm having a really difficult time following the code to try and understand the protocol used here. I'm not a Go-lang developer, and I'm trying to implement the protocol used in node for that very reason.

I've gotten as far as the initial handshake and then the code just loses all meaning to me. Too many levels of indirection to other libraries. It might have more meaning to someone more familiar with the Go stack.

Here's what I've been able to follow so far:

- Host spawns/forks process for plugin.
- Plugin checks environment variables for "Magic Cookie" to ensure it's hosted by the parent application.
- Plugin listens for unix/tcp socket in somewhat random location/port.
- Plugin reports over stdout to host with message formatted like:
- `BaseProtocolVersion|AppPluginProtocolVersion|SocketProtocol|SocketAddress`

After that I'm lost in multiplexers, redirected stdio streams, and go-specific network implementations. Once the plugin process starts listening on tcp/unix domain socket, I presume that the host application makes a connection to the socket. Who talks next, and what is the protocol?

Is there a flowchart or block diagram somewhere? Anything that describes the control flow for this protocol?

I don't expect a 100-page manual, but some next steps would be helpful. I'd be happy to produce some documentation for other people making this attempt if someone can help me get over this part of the learning curve.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.