mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-30 18:17:55 +00:00 
			
		
		
		
	 a401cc7cb5
			
		
	
	a401cc7cb5
	
	
	
		
			
			* Start work on context aware backends * Start work on moving the database plugins to gRPC in order to pass context * Add context to builtin database plugins * use byte slice instead of string * Context all the things * Move proto messages to the dbplugin package * Add a grpc mechanism for running backend plugins * Serve the GRPC plugin * Add backwards compatibility to the database plugins * Remove backend plugin changes * Remove backend plugin changes * Cleanup the transport implementations * If grpc connection is in an unexpected state restart the plugin * Fix tests * Fix tests * Remove context from the request object, replace it with context.TODO * Add a test to verify netRPC plugins still work * Remove unused mapstructure call * Code review fixes * Code review fixes * Code review fixes
		
			
				
	
	
		
			33 lines
		
	
	
		
			787 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			787 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package dbplugin
 | |
| 
 | |
| import (
 | |
| 	"crypto/tls"
 | |
| 
 | |
| 	"github.com/hashicorp/go-plugin"
 | |
| )
 | |
| 
 | |
| // Serve is called from within a plugin and wraps the provided
 | |
| // Database implementation in a databasePluginRPCServer object and starts a
 | |
| // RPC server.
 | |
| func Serve(db Database, tlsProvider func() (*tls.Config, error)) {
 | |
| 	plugin.Serve(ServeConfig(db, tlsProvider))
 | |
| }
 | |
| 
 | |
| func ServeConfig(db Database, tlsProvider func() (*tls.Config, error)) *plugin.ServeConfig {
 | |
| 	dbPlugin := &DatabasePlugin{
 | |
| 		impl: db,
 | |
| 	}
 | |
| 
 | |
| 	// pluginMap is the map of plugins we can dispense.
 | |
| 	var pluginMap = map[string]plugin.Plugin{
 | |
| 		"database": dbPlugin,
 | |
| 	}
 | |
| 
 | |
| 	return &plugin.ServeConfig{
 | |
| 		HandshakeConfig: handshakeConfig,
 | |
| 		Plugins:         pluginMap,
 | |
| 		TLSProvider:     tlsProvider,
 | |
| 		GRPCServer:      plugin.DefaultGRPCServer,
 | |
| 	}
 | |
| }
 |