mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-30 18:17:55 +00:00 
			
		
		
		
	 3565c90cf8
			
		
	
	3565c90cf8
	
	
	
		
			
			* feat: DB plugin multiplexing (#13734)
* WIP: start from main and get a plugin runner from core
* move MultiplexedClient map to plugin catalog
- call sys.NewPluginClient from PluginFactory
- updates to getPluginClient
- thread through isMetadataMode
* use go-plugin ClientProtocol interface
- call sys.NewPluginClient from dbplugin.NewPluginClient
* move PluginSets to dbplugin package
- export dbplugin HandshakeConfig
- small refactor of PluginCatalog.getPluginClient
* add removeMultiplexedClient; clean up on Close()
- call client.Kill from plugin catalog
- set rpcClient when muxed client exists
* add ID to dbplugin.DatabasePluginClient struct
* only create one plugin process per plugin type
* update NewPluginClient to return connection ID to sdk
- wrap grpc.ClientConn so we can inject the ID into context
- get ID from context on grpc server
* add v6 multiplexing  protocol version
* WIP: backwards compat for db plugins
* Ensure locking on plugin catalog access
- Create public GetPluginClient method for plugin catalog
- rename postgres db plugin
* use the New constructor for db plugins
* grpc server: use write lock for Close and rlock for CRUD
* cleanup MultiplexedClients on Close
* remove TODO
* fix multiplexing regression with grpc server connection
* cleanup grpc server instances on close
* embed ClientProtocol in Multiplexer interface
* use PluginClientConfig arg to make NewPluginClient plugin type agnostic
* create a new plugin process for non-muxed plugins
* feat: plugin multiplexing: handle plugin client cleanup (#13896)
* use closure for plugin client cleanup
* log and return errors; add comments
* move rpcClient wrapping to core for ID injection
* refactor core plugin client and sdk
* remove unused ID method
* refactor and only wrap clientConn on multiplexed plugins
* rename structs and do not export types
* Slight refactor of system view interface
* Revert "Slight refactor of system view interface"
This reverts commit 73d420e5cd.
* Revert "Revert "Slight refactor of system view interface""
This reverts commit f75527008a1db06d04a23e04c3059674be8adb5f.
* only provide pluginRunner arg to the internal newPluginClient method
* embed ClientProtocol in pluginClient and name logger
* Add back MLock support
* remove enableMlock arg from setupPluginCatalog
* rename plugin util interface to PluginClient
Co-authored-by: Brian Kassouf <bkassouf@hashicorp.com>
* feature: multiplexing: fix unit tests (#14007)
* fix grpc_server tests and add coverage
* update run_config tests
* add happy path test case for grpc_server ID from context
* update test helpers
* feat: multiplexing: handle v5 plugin compiled with new sdk
* add mux supported flag and increase test coverage
* set multiplexingSupport field in plugin server
* remove multiplexingSupport field in sdk
* revert postgres to non-multiplexed
* add comments on grpc server fields
* use pointer receiver on grpc server methods
* add changelog
* use pointer for grpcserver instance
* Use a gRPC server to determine if a plugin should be multiplexed
* Apply suggestions from code review
Co-authored-by: Brian Kassouf <briankassouf@users.noreply.github.com>
* add lock to removePluginClient
* add multiplexingSupport field to externalPlugin struct
* do not send nil to grpc MultiplexingSupport
* check err before logging
* handle locking scenario for cleanupFunc
* allow ServeConfigMultiplex to dispense v5 plugin
* reposition structs, add err check and comments
* add comment on locking for cleanupExternalPlugin
Co-authored-by: Brian Kassouf <bkassouf@hashicorp.com>
Co-authored-by: Brian Kassouf <briankassouf@users.noreply.github.com>
		
	
		
			
				
	
	
		
			102 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			102 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Code generated by protoc-gen-go-grpc. DO NOT EDIT.
 | |
| 
 | |
| package pluginutil
 | |
| 
 | |
| import (
 | |
| 	context "context"
 | |
| 	grpc "google.golang.org/grpc"
 | |
| 	codes "google.golang.org/grpc/codes"
 | |
| 	status "google.golang.org/grpc/status"
 | |
| )
 | |
| 
 | |
| // This is a compile-time assertion to ensure that this generated file
 | |
| // is compatible with the grpc package it is being compiled against.
 | |
| // Requires gRPC-Go v1.32.0 or later.
 | |
| const _ = grpc.SupportPackageIsVersion7
 | |
| 
 | |
| // PluginMultiplexingClient is the client API for PluginMultiplexing service.
 | |
| //
 | |
| // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
 | |
| type PluginMultiplexingClient interface {
 | |
| 	MultiplexingSupport(ctx context.Context, in *MultiplexingSupportRequest, opts ...grpc.CallOption) (*MultiplexingSupportResponse, error)
 | |
| }
 | |
| 
 | |
| type pluginMultiplexingClient struct {
 | |
| 	cc grpc.ClientConnInterface
 | |
| }
 | |
| 
 | |
| func NewPluginMultiplexingClient(cc grpc.ClientConnInterface) PluginMultiplexingClient {
 | |
| 	return &pluginMultiplexingClient{cc}
 | |
| }
 | |
| 
 | |
| func (c *pluginMultiplexingClient) MultiplexingSupport(ctx context.Context, in *MultiplexingSupportRequest, opts ...grpc.CallOption) (*MultiplexingSupportResponse, error) {
 | |
| 	out := new(MultiplexingSupportResponse)
 | |
| 	err := c.cc.Invoke(ctx, "/pluginutil.multiplexing.PluginMultiplexing/MultiplexingSupport", in, out, opts...)
 | |
| 	if err != nil {
 | |
| 		return nil, err
 | |
| 	}
 | |
| 	return out, nil
 | |
| }
 | |
| 
 | |
| // PluginMultiplexingServer is the server API for PluginMultiplexing service.
 | |
| // All implementations must embed UnimplementedPluginMultiplexingServer
 | |
| // for forward compatibility
 | |
| type PluginMultiplexingServer interface {
 | |
| 	MultiplexingSupport(context.Context, *MultiplexingSupportRequest) (*MultiplexingSupportResponse, error)
 | |
| 	mustEmbedUnimplementedPluginMultiplexingServer()
 | |
| }
 | |
| 
 | |
| // UnimplementedPluginMultiplexingServer must be embedded to have forward compatible implementations.
 | |
| type UnimplementedPluginMultiplexingServer struct {
 | |
| }
 | |
| 
 | |
| func (UnimplementedPluginMultiplexingServer) MultiplexingSupport(context.Context, *MultiplexingSupportRequest) (*MultiplexingSupportResponse, error) {
 | |
| 	return nil, status.Errorf(codes.Unimplemented, "method MultiplexingSupport not implemented")
 | |
| }
 | |
| func (UnimplementedPluginMultiplexingServer) mustEmbedUnimplementedPluginMultiplexingServer() {}
 | |
| 
 | |
| // UnsafePluginMultiplexingServer may be embedded to opt out of forward compatibility for this service.
 | |
| // Use of this interface is not recommended, as added methods to PluginMultiplexingServer will
 | |
| // result in compilation errors.
 | |
| type UnsafePluginMultiplexingServer interface {
 | |
| 	mustEmbedUnimplementedPluginMultiplexingServer()
 | |
| }
 | |
| 
 | |
| func RegisterPluginMultiplexingServer(s grpc.ServiceRegistrar, srv PluginMultiplexingServer) {
 | |
| 	s.RegisterService(&PluginMultiplexing_ServiceDesc, srv)
 | |
| }
 | |
| 
 | |
| func _PluginMultiplexing_MultiplexingSupport_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
 | |
| 	in := new(MultiplexingSupportRequest)
 | |
| 	if err := dec(in); err != nil {
 | |
| 		return nil, err
 | |
| 	}
 | |
| 	if interceptor == nil {
 | |
| 		return srv.(PluginMultiplexingServer).MultiplexingSupport(ctx, in)
 | |
| 	}
 | |
| 	info := &grpc.UnaryServerInfo{
 | |
| 		Server:     srv,
 | |
| 		FullMethod: "/pluginutil.multiplexing.PluginMultiplexing/MultiplexingSupport",
 | |
| 	}
 | |
| 	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
 | |
| 		return srv.(PluginMultiplexingServer).MultiplexingSupport(ctx, req.(*MultiplexingSupportRequest))
 | |
| 	}
 | |
| 	return interceptor(ctx, in, info, handler)
 | |
| }
 | |
| 
 | |
| // PluginMultiplexing_ServiceDesc is the grpc.ServiceDesc for PluginMultiplexing service.
 | |
| // It's only intended for direct use with grpc.RegisterService,
 | |
| // and not to be introspected or modified (even as a copy)
 | |
| var PluginMultiplexing_ServiceDesc = grpc.ServiceDesc{
 | |
| 	ServiceName: "pluginutil.multiplexing.PluginMultiplexing",
 | |
| 	HandlerType: (*PluginMultiplexingServer)(nil),
 | |
| 	Methods: []grpc.MethodDesc{
 | |
| 		{
 | |
| 			MethodName: "MultiplexingSupport",
 | |
| 			Handler:    _PluginMultiplexing_MultiplexingSupport_Handler,
 | |
| 		},
 | |
| 	},
 | |
| 	Streams:  []grpc.StreamDesc{},
 | |
| 	Metadata: "sdk/helper/pluginutil/multiplexing.proto",
 | |
| }
 |