SDK Reference (original) (raw)

The GatewayD plugin SDK provides a number of interfaces, structs and methods to help you build your plugin. This section provides a reference to all of them. The SDK is built for Go, but the protocol buffers definitions can be used to build plugins in other languages.

This documentation is not complete. Please refer to the SDK source code for more information. Also, it might be removed in the future in favor of GoDoc.

The SDK is still in development and subject to change.

Packages

The root of the SDK is the github.com/gatewayd-io/gatewayd-plugin-sdk. It contains the following sub-packages:

config

  func GetEnv(key, fallback string) string  

databases/postgres

  func IsPostgresStartupMessage(message []byte) bool  
  func DecodeBytes(encoded string) ([]byte, error)  
  func HandleClientMessage(req *v1.Struct, logger hclog.Logger) (*v1.Struct, error)  
  func HandleServerMessage(resp *v1.Struct, logger hclog.Logger) (*v1.Struct, error)  
  func GetQueryFromRequest(req *v1.Struct) (string, error)  
  func GetTablesFromQuery(query string) ([]string, error)  

logging

  func GetLogLevel(level string) hclog.Level  

metrics

  func NewMetricsConfig(config map[string]interface{}) *MetricsConfig  
  func ExposeMetrics(config *MetricsConfig, logger hclog.Logger) error  

plugin

  func DefaultGRPCServer(opts []grpc.ServerOption) *grpc.Server  
  func GetAttr(req *v1.Struct, key string, defaultValue interface{}) interface{}  

plugin/v1

  func GetPluginMap(pluginName string) map[string]goplugin.Plugin  
  func GetPluginSetMap(plugins map[string]goplugin.Plugin) goplugin.PluginSet