mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2025-09-19 20:26:26 +08:00
feat: Implement plugin architecture with gRPC support
- Added driver initialization for gRPC plugins in internal/bootstrap/driver.go. - Introduced configuration structures and protobuf definitions for driver plugins in proto/driver/config.proto and proto/driver/driver.proto. - Implemented gRPC server and client interfaces for driver plugins in shared/driver/grpc.go. - Created common response handling utilities in server/common/common.go and server/common/resp.go. - Developed plugin registration endpoint in server/handles/plugin.go. - Added test cases for plugin functionality in shared/driver/plugin_test.go. - Defined plugin reattachment configuration model in shared/model/plugin.go.
This commit is contained in:
120
proto/driver/driver_grpc.pb.go
Normal file
120
proto/driver/driver_grpc.pb.go
Normal file
@ -0,0 +1,120 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.5.1
|
||||
// - protoc (unknown)
|
||||
// source: proto/driver/driver.proto
|
||||
|
||||
package driver
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
emptypb "google.golang.org/protobuf/types/known/emptypb"
|
||||
)
|
||||
|
||||
// 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.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
Driver_Config_FullMethodName = "/driver.Driver/Config"
|
||||
)
|
||||
|
||||
// DriverClient is the client API for Driver 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 DriverClient interface {
|
||||
Config(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*Config, error)
|
||||
}
|
||||
|
||||
type driverClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewDriverClient(cc grpc.ClientConnInterface) DriverClient {
|
||||
return &driverClient{cc}
|
||||
}
|
||||
|
||||
func (c *driverClient) Config(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*Config, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(Config)
|
||||
err := c.cc.Invoke(ctx, Driver_Config_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// DriverServer is the server API for Driver service.
|
||||
// All implementations should embed UnimplementedDriverServer
|
||||
// for forward compatibility.
|
||||
type DriverServer interface {
|
||||
Config(context.Context, *emptypb.Empty) (*Config, error)
|
||||
}
|
||||
|
||||
// UnimplementedDriverServer should be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedDriverServer struct{}
|
||||
|
||||
func (UnimplementedDriverServer) Config(context.Context, *emptypb.Empty) (*Config, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Config not implemented")
|
||||
}
|
||||
func (UnimplementedDriverServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeDriverServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to DriverServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeDriverServer interface {
|
||||
mustEmbedUnimplementedDriverServer()
|
||||
}
|
||||
|
||||
func RegisterDriverServer(s grpc.ServiceRegistrar, srv DriverServer) {
|
||||
// If the following call pancis, it indicates UnimplementedDriverServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&Driver_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _Driver_Config_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(emptypb.Empty)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(DriverServer).Config(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Driver_Config_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(DriverServer).Config(ctx, req.(*emptypb.Empty))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Driver_ServiceDesc is the grpc.ServiceDesc for Driver service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Driver_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "driver.Driver",
|
||||
HandlerType: (*DriverServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Config",
|
||||
Handler: _Driver_Config_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "proto/driver/driver.proto",
|
||||
}
|
Reference in New Issue
Block a user