mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-30 10:12:35 +00:00 
			
		
		
		
	refactor database plugin SDK (#29479)
* prepare for enterprise database plugin SDK development
This commit is contained in:
		| @@ -12,6 +12,7 @@ import ( | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/golang/protobuf/ptypes" | ||||
|  | ||||
| 	"github.com/hashicorp/vault/sdk/database/dbplugin/v5/proto" | ||||
| 	"github.com/hashicorp/vault/sdk/helper/pluginutil" | ||||
| 	"github.com/hashicorp/vault/sdk/logical" | ||||
| @@ -25,6 +26,7 @@ var ( | ||||
| ) | ||||
|  | ||||
| type gRPCClient struct { | ||||
| 	entGRPCClient | ||||
| 	client        proto.DatabaseClient | ||||
| 	versionClient logical.PluginVersionClient | ||||
| 	doneCtx       context.Context | ||||
| @@ -285,20 +287,6 @@ func (c gRPCClient) Type() (string, error) { | ||||
| 	return typeResp.GetType(), nil | ||||
| } | ||||
|  | ||||
| func (c gRPCClient) Close() error { | ||||
| 	ctx, cancel := getContextWithTimeout(pluginutil.PluginGRPCTimeoutClose) | ||||
| 	defer cancel() | ||||
|  | ||||
| 	_, err := c.client.Close(ctx, &proto.Empty{}) | ||||
| 	if err != nil { | ||||
| 		if c.doneCtx.Err() != nil { | ||||
| 			return ErrPluginShutdown | ||||
| 		} | ||||
| 		return err | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func getContextWithTimeout(env string) (context.Context, context.CancelFunc) { | ||||
| 	timeout := 1 // default timeout | ||||
| 	if envTimeout, err := strconv.Atoi(os.Getenv(env)); err == nil && envTimeout > 0 { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Thy Ton
					Thy Ton