2023-03-09 19:40:23 +00:00
|
|
|
package resource
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
|
2023-03-27 15:35:39 +00:00
|
|
|
"github.com/hashicorp/consul/internal/resource"
|
|
|
|
"github.com/hashicorp/consul/internal/storage"
|
2023-03-09 19:40:23 +00:00
|
|
|
"github.com/hashicorp/consul/proto-public/pbresource"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Server struct {
|
|
|
|
Config
|
|
|
|
}
|
|
|
|
|
|
|
|
type Config struct {
|
2023-03-27 15:35:39 +00:00
|
|
|
registry resource.Registry
|
|
|
|
backend storage.Backend
|
|
|
|
}
|
|
|
|
|
|
|
|
//go:generate mockery --name Backend --inpackage
|
|
|
|
type Backend interface {
|
|
|
|
storage.Backend
|
2023-03-09 19:40:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewServer(cfg Config) *Server {
|
|
|
|
return &Server{cfg}
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ pbresource.ResourceServiceServer = (*Server)(nil)
|
|
|
|
|
|
|
|
func (s *Server) Register(grpcServer *grpc.Server) {
|
|
|
|
pbresource.RegisterResourceServiceServer(grpcServer, s)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) Write(ctx context.Context, req *pbresource.WriteRequest) (*pbresource.WriteResponse, error) {
|
|
|
|
// TODO
|
|
|
|
return &pbresource.WriteResponse{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) WriteStatus(ctx context.Context, req *pbresource.WriteStatusRequest) (*pbresource.WriteStatusResponse, error) {
|
|
|
|
// TODO
|
|
|
|
return &pbresource.WriteStatusResponse{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) List(ctx context.Context, req *pbresource.ListRequest) (*pbresource.ListResponse, error) {
|
|
|
|
// TODO
|
|
|
|
return &pbresource.ListResponse{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) Delete(ctx context.Context, req *pbresource.DeleteRequest) (*pbresource.DeleteResponse, error) {
|
|
|
|
// TODO
|
|
|
|
return &pbresource.DeleteResponse{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) Watch(req *pbresource.WatchRequest, ws pbresource.ResourceService_WatchServer) error {
|
|
|
|
// TODO
|
|
|
|
return nil
|
|
|
|
}
|