How hashicorp/go-plugin works
Main Components
a) Host Process (Main Application)
• This as a primary container at the top
• Subcomponents:
• Plugin Client Manager
• RPC/gRPC Client Interface
• MuxBroker (for multiplexing connections)
• Logger Integration
b) Plugin Process (Subprocess)
• This as a parallel container
• Subcomponents:
• Plugin Server
• RPC/gRPC Server Interface
• Interface Implementation
c) Communication Layer
• Bidirectional channels between Host and Plugin
• Both supported protocols:
• net/rpc channel
• gRPC channel (HTTP/2)
• Multiplexed connections
Key Relationships to Highlight
• Host Process → Plugin Launch
• Plugin Registration
• Interface Discovery
• Bidirectional Communication
• Security Components:
• TLS Connection (optional)
• Checksum Verification
• Protocol Version Validation
Specific Implementation Details
• Blue rectangles for primary processes (Host/Plugin)
• Green ovals for communication protocols
• Yellow diamonds for security components
• Orange rectangles for brokers/multiplexers
• Purple rectangles for interface implementations
Special Features
• Stdout/stderr syncing mechanism
• Logging bridge
• Demonstrate the reattachment capability
• TTY preservation system
Architectural Patterns to Emphasize
• Process Isolation boundary
• Multiplexing pattern
• Interface-based communication
• Security boundaries
[Host Process Layer]
• ↕
[Communication/Security Layer]
• ↕
[Plugin Process Layer]
Important Implementation Notes:
• Use the file structure from internal/plugin/ for protocol definitions
• Relationship between grpc_broker.go and mux_broker.go
• How the cmdrunner package manages plugin processes
• Demonstrate the relationship between client.go and server.go
Remember to:
Plugin discovery mechanisms
• Process isolation
• Cross-language support
• Bidirectional communication
• Security measures
• Logging system
• Protocol versioning
• TTY handling
• Reattachment capabilities
This will provide a comprehensive view of the plugin system while maintaining clarity about the separation of concerns and communication patterns.