42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package connector
|
|
|
|
import (
|
|
"context"
|
|
|
|
goplugin "github.com/hashicorp/go-plugin"
|
|
"google.golang.org/grpc"
|
|
|
|
connectorv1 "github.com/samcharles93/archipelago/sdk/connector/v1"
|
|
)
|
|
|
|
const surface = "connector"
|
|
|
|
type plugin struct {
|
|
goplugin.NetRPCUnsupportedPlugin
|
|
impl connectorv1.ConnectorServiceServer
|
|
}
|
|
|
|
func (p *plugin) GRPCServer(_ *goplugin.GRPCBroker, s *grpc.Server) error {
|
|
connectorv1.RegisterConnectorServiceServer(s, p.impl)
|
|
return nil
|
|
}
|
|
|
|
func (*plugin) GRPCClient(context.Context, *goplugin.GRPCBroker, *grpc.ClientConn) (any, error) {
|
|
return nil, nil
|
|
}
|
|
|
|
// Serve runs the connector build returns as the extension process. build is
|
|
// called on every Configure. Serve returns when archie-core stops the
|
|
// extension.
|
|
func Serve(build func(Config) (Connector, error)) {
|
|
goplugin.Serve(&goplugin.ServeConfig{
|
|
HandshakeConfig: goplugin.HandshakeConfig{
|
|
ProtocolVersion: 1,
|
|
MagicCookieKey: "ARCHIE_EXTENSION",
|
|
MagicCookieValue: "archie",
|
|
},
|
|
Plugins: goplugin.PluginSet{surface: &plugin{impl: &server{build: build}}},
|
|
GRPCServer: goplugin.DefaultGRPCServer,
|
|
})
|
|
}
|