github.com/qiniu/go-sdk/v7@v7.27.0/sandbox/internal/envdapi/filesystem/filesystemconnect/filesystem.connect.go (about)

     1  // Code generated by protoc-gen-connect-go. DO NOT EDIT.
     2  //
     3  // Source: filesystem/filesystem.proto
     4  
     5  package filesystemconnect
     6  
     7  import (
     8  	connect "connectrpc.com/connect"
     9  	context "context"
    10  	errors "errors"
    11  	filesystem "github.com/qiniu/go-sdk/v7/sandbox/internal/envdapi/filesystem"
    12  	http "net/http"
    13  	strings "strings"
    14  )
    15  
    16  // This is a compile-time assertion to ensure that this generated file and the connect package are
    17  // compatible. If you get a compiler error that this constant is not defined, this code was
    18  // generated with a version of connect newer than the one compiled into your binary. You can fix the
    19  // problem by either regenerating this code with an older version of connect or updating the connect
    20  // version compiled into your binary.
    21  const _ = connect.IsAtLeastVersion1_13_0
    22  
    23  const (
    24  	// FilesystemName is the fully-qualified name of the Filesystem service.
    25  	FilesystemName = "filesystem.Filesystem"
    26  )
    27  
    28  // These constants are the fully-qualified names of the RPCs defined in this package. They're
    29  // exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
    30  //
    31  // Note that these are different from the fully-qualified method names used by
    32  // google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
    33  // reflection-formatted method names, remove the leading slash and convert the remaining slash to a
    34  // period.
    35  const (
    36  	// FilesystemStatProcedure is the fully-qualified name of the Filesystem's Stat RPC.
    37  	FilesystemStatProcedure = "/filesystem.Filesystem/Stat"
    38  	// FilesystemMakeDirProcedure is the fully-qualified name of the Filesystem's MakeDir RPC.
    39  	FilesystemMakeDirProcedure = "/filesystem.Filesystem/MakeDir"
    40  	// FilesystemMoveProcedure is the fully-qualified name of the Filesystem's Move RPC.
    41  	FilesystemMoveProcedure = "/filesystem.Filesystem/Move"
    42  	// FilesystemListDirProcedure is the fully-qualified name of the Filesystem's ListDir RPC.
    43  	FilesystemListDirProcedure = "/filesystem.Filesystem/ListDir"
    44  	// FilesystemRemoveProcedure is the fully-qualified name of the Filesystem's Remove RPC.
    45  	FilesystemRemoveProcedure = "/filesystem.Filesystem/Remove"
    46  	// FilesystemWatchDirProcedure is the fully-qualified name of the Filesystem's WatchDir RPC.
    47  	FilesystemWatchDirProcedure = "/filesystem.Filesystem/WatchDir"
    48  	// FilesystemCreateWatcherProcedure is the fully-qualified name of the Filesystem's CreateWatcher
    49  	// RPC.
    50  	FilesystemCreateWatcherProcedure = "/filesystem.Filesystem/CreateWatcher"
    51  	// FilesystemGetWatcherEventsProcedure is the fully-qualified name of the Filesystem's
    52  	// GetWatcherEvents RPC.
    53  	FilesystemGetWatcherEventsProcedure = "/filesystem.Filesystem/GetWatcherEvents"
    54  	// FilesystemRemoveWatcherProcedure is the fully-qualified name of the Filesystem's RemoveWatcher
    55  	// RPC.
    56  	FilesystemRemoveWatcherProcedure = "/filesystem.Filesystem/RemoveWatcher"
    57  )
    58  
    59  // FilesystemClient is a client for the filesystem.Filesystem service.
    60  type FilesystemClient interface {
    61  	Stat(context.Context, *connect.Request[filesystem.StatRequest]) (*connect.Response[filesystem.StatResponse], error)
    62  	MakeDir(context.Context, *connect.Request[filesystem.MakeDirRequest]) (*connect.Response[filesystem.MakeDirResponse], error)
    63  	Move(context.Context, *connect.Request[filesystem.MoveRequest]) (*connect.Response[filesystem.MoveResponse], error)
    64  	ListDir(context.Context, *connect.Request[filesystem.ListDirRequest]) (*connect.Response[filesystem.ListDirResponse], error)
    65  	Remove(context.Context, *connect.Request[filesystem.RemoveRequest]) (*connect.Response[filesystem.RemoveResponse], error)
    66  	WatchDir(context.Context, *connect.Request[filesystem.WatchDirRequest]) (*connect.ServerStreamForClient[filesystem.WatchDirResponse], error)
    67  	// Non-streaming versions of WatchDir
    68  	CreateWatcher(context.Context, *connect.Request[filesystem.CreateWatcherRequest]) (*connect.Response[filesystem.CreateWatcherResponse], error)
    69  	GetWatcherEvents(context.Context, *connect.Request[filesystem.GetWatcherEventsRequest]) (*connect.Response[filesystem.GetWatcherEventsResponse], error)
    70  	RemoveWatcher(context.Context, *connect.Request[filesystem.RemoveWatcherRequest]) (*connect.Response[filesystem.RemoveWatcherResponse], error)
    71  }
    72  
    73  // NewFilesystemClient constructs a client for the filesystem.Filesystem service. By default, it
    74  // uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends
    75  // uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or
    76  // connect.WithGRPCWeb() options.
    77  //
    78  // The URL supplied here should be the base URL for the Connect or gRPC server (for example,
    79  // http://api.acme.com or https://acme.com/grpc).
    80  func NewFilesystemClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) FilesystemClient {
    81  	baseURL = strings.TrimRight(baseURL, "/")
    82  	filesystemMethods := filesystem.File_filesystem_filesystem_proto.Services().ByName("Filesystem").Methods()
    83  	return &filesystemClient{
    84  		stat: connect.NewClient[filesystem.StatRequest, filesystem.StatResponse](
    85  			httpClient,
    86  			baseURL+FilesystemStatProcedure,
    87  			connect.WithSchema(filesystemMethods.ByName("Stat")),
    88  			connect.WithClientOptions(opts...),
    89  		),
    90  		makeDir: connect.NewClient[filesystem.MakeDirRequest, filesystem.MakeDirResponse](
    91  			httpClient,
    92  			baseURL+FilesystemMakeDirProcedure,
    93  			connect.WithSchema(filesystemMethods.ByName("MakeDir")),
    94  			connect.WithClientOptions(opts...),
    95  		),
    96  		move: connect.NewClient[filesystem.MoveRequest, filesystem.MoveResponse](
    97  			httpClient,
    98  			baseURL+FilesystemMoveProcedure,
    99  			connect.WithSchema(filesystemMethods.ByName("Move")),
   100  			connect.WithClientOptions(opts...),
   101  		),
   102  		listDir: connect.NewClient[filesystem.ListDirRequest, filesystem.ListDirResponse](
   103  			httpClient,
   104  			baseURL+FilesystemListDirProcedure,
   105  			connect.WithSchema(filesystemMethods.ByName("ListDir")),
   106  			connect.WithClientOptions(opts...),
   107  		),
   108  		remove: connect.NewClient[filesystem.RemoveRequest, filesystem.RemoveResponse](
   109  			httpClient,
   110  			baseURL+FilesystemRemoveProcedure,
   111  			connect.WithSchema(filesystemMethods.ByName("Remove")),
   112  			connect.WithClientOptions(opts...),
   113  		),
   114  		watchDir: connect.NewClient[filesystem.WatchDirRequest, filesystem.WatchDirResponse](
   115  			httpClient,
   116  			baseURL+FilesystemWatchDirProcedure,
   117  			connect.WithSchema(filesystemMethods.ByName("WatchDir")),
   118  			connect.WithClientOptions(opts...),
   119  		),
   120  		createWatcher: connect.NewClient[filesystem.CreateWatcherRequest, filesystem.CreateWatcherResponse](
   121  			httpClient,
   122  			baseURL+FilesystemCreateWatcherProcedure,
   123  			connect.WithSchema(filesystemMethods.ByName("CreateWatcher")),
   124  			connect.WithClientOptions(opts...),
   125  		),
   126  		getWatcherEvents: connect.NewClient[filesystem.GetWatcherEventsRequest, filesystem.GetWatcherEventsResponse](
   127  			httpClient,
   128  			baseURL+FilesystemGetWatcherEventsProcedure,
   129  			connect.WithSchema(filesystemMethods.ByName("GetWatcherEvents")),
   130  			connect.WithClientOptions(opts...),
   131  		),
   132  		removeWatcher: connect.NewClient[filesystem.RemoveWatcherRequest, filesystem.RemoveWatcherResponse](
   133  			httpClient,
   134  			baseURL+FilesystemRemoveWatcherProcedure,
   135  			connect.WithSchema(filesystemMethods.ByName("RemoveWatcher")),
   136  			connect.WithClientOptions(opts...),
   137  		),
   138  	}
   139  }
   140  
   141  // filesystemClient implements FilesystemClient.
   142  type filesystemClient struct {
   143  	stat             *connect.Client[filesystem.StatRequest, filesystem.StatResponse]
   144  	makeDir          *connect.Client[filesystem.MakeDirRequest, filesystem.MakeDirResponse]
   145  	move             *connect.Client[filesystem.MoveRequest, filesystem.MoveResponse]
   146  	listDir          *connect.Client[filesystem.ListDirRequest, filesystem.ListDirResponse]
   147  	remove           *connect.Client[filesystem.RemoveRequest, filesystem.RemoveResponse]
   148  	watchDir         *connect.Client[filesystem.WatchDirRequest, filesystem.WatchDirResponse]
   149  	createWatcher    *connect.Client[filesystem.CreateWatcherRequest, filesystem.CreateWatcherResponse]
   150  	getWatcherEvents *connect.Client[filesystem.GetWatcherEventsRequest, filesystem.GetWatcherEventsResponse]
   151  	removeWatcher    *connect.Client[filesystem.RemoveWatcherRequest, filesystem.RemoveWatcherResponse]
   152  }
   153  
   154  // Stat calls filesystem.Filesystem.Stat.
   155  func (c *filesystemClient) Stat(ctx context.Context, req *connect.Request[filesystem.StatRequest]) (*connect.Response[filesystem.StatResponse], error) {
   156  	return c.stat.CallUnary(ctx, req)
   157  }
   158  
   159  // MakeDir calls filesystem.Filesystem.MakeDir.
   160  func (c *filesystemClient) MakeDir(ctx context.Context, req *connect.Request[filesystem.MakeDirRequest]) (*connect.Response[filesystem.MakeDirResponse], error) {
   161  	return c.makeDir.CallUnary(ctx, req)
   162  }
   163  
   164  // Move calls filesystem.Filesystem.Move.
   165  func (c *filesystemClient) Move(ctx context.Context, req *connect.Request[filesystem.MoveRequest]) (*connect.Response[filesystem.MoveResponse], error) {
   166  	return c.move.CallUnary(ctx, req)
   167  }
   168  
   169  // ListDir calls filesystem.Filesystem.ListDir.
   170  func (c *filesystemClient) ListDir(ctx context.Context, req *connect.Request[filesystem.ListDirRequest]) (*connect.Response[filesystem.ListDirResponse], error) {
   171  	return c.listDir.CallUnary(ctx, req)
   172  }
   173  
   174  // Remove calls filesystem.Filesystem.Remove.
   175  func (c *filesystemClient) Remove(ctx context.Context, req *connect.Request[filesystem.RemoveRequest]) (*connect.Response[filesystem.RemoveResponse], error) {
   176  	return c.remove.CallUnary(ctx, req)
   177  }
   178  
   179  // WatchDir calls filesystem.Filesystem.WatchDir.
   180  func (c *filesystemClient) WatchDir(ctx context.Context, req *connect.Request[filesystem.WatchDirRequest]) (*connect.ServerStreamForClient[filesystem.WatchDirResponse], error) {
   181  	return c.watchDir.CallServerStream(ctx, req)
   182  }
   183  
   184  // CreateWatcher calls filesystem.Filesystem.CreateWatcher.
   185  func (c *filesystemClient) CreateWatcher(ctx context.Context, req *connect.Request[filesystem.CreateWatcherRequest]) (*connect.Response[filesystem.CreateWatcherResponse], error) {
   186  	return c.createWatcher.CallUnary(ctx, req)
   187  }
   188  
   189  // GetWatcherEvents calls filesystem.Filesystem.GetWatcherEvents.
   190  func (c *filesystemClient) GetWatcherEvents(ctx context.Context, req *connect.Request[filesystem.GetWatcherEventsRequest]) (*connect.Response[filesystem.GetWatcherEventsResponse], error) {
   191  	return c.getWatcherEvents.CallUnary(ctx, req)
   192  }
   193  
   194  // RemoveWatcher calls filesystem.Filesystem.RemoveWatcher.
   195  func (c *filesystemClient) RemoveWatcher(ctx context.Context, req *connect.Request[filesystem.RemoveWatcherRequest]) (*connect.Response[filesystem.RemoveWatcherResponse], error) {
   196  	return c.removeWatcher.CallUnary(ctx, req)
   197  }
   198  
   199  // FilesystemHandler is an implementation of the filesystem.Filesystem service.
   200  type FilesystemHandler interface {
   201  	Stat(context.Context, *connect.Request[filesystem.StatRequest]) (*connect.Response[filesystem.StatResponse], error)
   202  	MakeDir(context.Context, *connect.Request[filesystem.MakeDirRequest]) (*connect.Response[filesystem.MakeDirResponse], error)
   203  	Move(context.Context, *connect.Request[filesystem.MoveRequest]) (*connect.Response[filesystem.MoveResponse], error)
   204  	ListDir(context.Context, *connect.Request[filesystem.ListDirRequest]) (*connect.Response[filesystem.ListDirResponse], error)
   205  	Remove(context.Context, *connect.Request[filesystem.RemoveRequest]) (*connect.Response[filesystem.RemoveResponse], error)
   206  	WatchDir(context.Context, *connect.Request[filesystem.WatchDirRequest], *connect.ServerStream[filesystem.WatchDirResponse]) error
   207  	// Non-streaming versions of WatchDir
   208  	CreateWatcher(context.Context, *connect.Request[filesystem.CreateWatcherRequest]) (*connect.Response[filesystem.CreateWatcherResponse], error)
   209  	GetWatcherEvents(context.Context, *connect.Request[filesystem.GetWatcherEventsRequest]) (*connect.Response[filesystem.GetWatcherEventsResponse], error)
   210  	RemoveWatcher(context.Context, *connect.Request[filesystem.RemoveWatcherRequest]) (*connect.Response[filesystem.RemoveWatcherResponse], error)
   211  }
   212  
   213  // NewFilesystemHandler builds an HTTP handler from the service implementation. It returns the path
   214  // on which to mount the handler and the handler itself.
   215  //
   216  // By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
   217  // and JSON codecs. They also support gzip compression.
   218  func NewFilesystemHandler(svc FilesystemHandler, opts ...connect.HandlerOption) (string, http.Handler) {
   219  	filesystemMethods := filesystem.File_filesystem_filesystem_proto.Services().ByName("Filesystem").Methods()
   220  	filesystemStatHandler := connect.NewUnaryHandler(
   221  		FilesystemStatProcedure,
   222  		svc.Stat,
   223  		connect.WithSchema(filesystemMethods.ByName("Stat")),
   224  		connect.WithHandlerOptions(opts...),
   225  	)
   226  	filesystemMakeDirHandler := connect.NewUnaryHandler(
   227  		FilesystemMakeDirProcedure,
   228  		svc.MakeDir,
   229  		connect.WithSchema(filesystemMethods.ByName("MakeDir")),
   230  		connect.WithHandlerOptions(opts...),
   231  	)
   232  	filesystemMoveHandler := connect.NewUnaryHandler(
   233  		FilesystemMoveProcedure,
   234  		svc.Move,
   235  		connect.WithSchema(filesystemMethods.ByName("Move")),
   236  		connect.WithHandlerOptions(opts...),
   237  	)
   238  	filesystemListDirHandler := connect.NewUnaryHandler(
   239  		FilesystemListDirProcedure,
   240  		svc.ListDir,
   241  		connect.WithSchema(filesystemMethods.ByName("ListDir")),
   242  		connect.WithHandlerOptions(opts...),
   243  	)
   244  	filesystemRemoveHandler := connect.NewUnaryHandler(
   245  		FilesystemRemoveProcedure,
   246  		svc.Remove,
   247  		connect.WithSchema(filesystemMethods.ByName("Remove")),
   248  		connect.WithHandlerOptions(opts...),
   249  	)
   250  	filesystemWatchDirHandler := connect.NewServerStreamHandler(
   251  		FilesystemWatchDirProcedure,
   252  		svc.WatchDir,
   253  		connect.WithSchema(filesystemMethods.ByName("WatchDir")),
   254  		connect.WithHandlerOptions(opts...),
   255  	)
   256  	filesystemCreateWatcherHandler := connect.NewUnaryHandler(
   257  		FilesystemCreateWatcherProcedure,
   258  		svc.CreateWatcher,
   259  		connect.WithSchema(filesystemMethods.ByName("CreateWatcher")),
   260  		connect.WithHandlerOptions(opts...),
   261  	)
   262  	filesystemGetWatcherEventsHandler := connect.NewUnaryHandler(
   263  		FilesystemGetWatcherEventsProcedure,
   264  		svc.GetWatcherEvents,
   265  		connect.WithSchema(filesystemMethods.ByName("GetWatcherEvents")),
   266  		connect.WithHandlerOptions(opts...),
   267  	)
   268  	filesystemRemoveWatcherHandler := connect.NewUnaryHandler(
   269  		FilesystemRemoveWatcherProcedure,
   270  		svc.RemoveWatcher,
   271  		connect.WithSchema(filesystemMethods.ByName("RemoveWatcher")),
   272  		connect.WithHandlerOptions(opts...),
   273  	)
   274  	return "/filesystem.Filesystem/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
   275  		switch r.URL.Path {
   276  		case FilesystemStatProcedure:
   277  			filesystemStatHandler.ServeHTTP(w, r)
   278  		case FilesystemMakeDirProcedure:
   279  			filesystemMakeDirHandler.ServeHTTP(w, r)
   280  		case FilesystemMoveProcedure:
   281  			filesystemMoveHandler.ServeHTTP(w, r)
   282  		case FilesystemListDirProcedure:
   283  			filesystemListDirHandler.ServeHTTP(w, r)
   284  		case FilesystemRemoveProcedure:
   285  			filesystemRemoveHandler.ServeHTTP(w, r)
   286  		case FilesystemWatchDirProcedure:
   287  			filesystemWatchDirHandler.ServeHTTP(w, r)
   288  		case FilesystemCreateWatcherProcedure:
   289  			filesystemCreateWatcherHandler.ServeHTTP(w, r)
   290  		case FilesystemGetWatcherEventsProcedure:
   291  			filesystemGetWatcherEventsHandler.ServeHTTP(w, r)
   292  		case FilesystemRemoveWatcherProcedure:
   293  			filesystemRemoveWatcherHandler.ServeHTTP(w, r)
   294  		default:
   295  			http.NotFound(w, r)
   296  		}
   297  	})
   298  }
   299  
   300  // UnimplementedFilesystemHandler returns CodeUnimplemented from all methods.
   301  type UnimplementedFilesystemHandler struct{}
   302  
   303  func (UnimplementedFilesystemHandler) Stat(context.Context, *connect.Request[filesystem.StatRequest]) (*connect.Response[filesystem.StatResponse], error) {
   304  	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("filesystem.Filesystem.Stat is not implemented"))
   305  }
   306  
   307  func (UnimplementedFilesystemHandler) MakeDir(context.Context, *connect.Request[filesystem.MakeDirRequest]) (*connect.Response[filesystem.MakeDirResponse], error) {
   308  	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("filesystem.Filesystem.MakeDir is not implemented"))
   309  }
   310  
   311  func (UnimplementedFilesystemHandler) Move(context.Context, *connect.Request[filesystem.MoveRequest]) (*connect.Response[filesystem.MoveResponse], error) {
   312  	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("filesystem.Filesystem.Move is not implemented"))
   313  }
   314  
   315  func (UnimplementedFilesystemHandler) ListDir(context.Context, *connect.Request[filesystem.ListDirRequest]) (*connect.Response[filesystem.ListDirResponse], error) {
   316  	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("filesystem.Filesystem.ListDir is not implemented"))
   317  }
   318  
   319  func (UnimplementedFilesystemHandler) Remove(context.Context, *connect.Request[filesystem.RemoveRequest]) (*connect.Response[filesystem.RemoveResponse], error) {
   320  	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("filesystem.Filesystem.Remove is not implemented"))
   321  }
   322  
   323  func (UnimplementedFilesystemHandler) WatchDir(context.Context, *connect.Request[filesystem.WatchDirRequest], *connect.ServerStream[filesystem.WatchDirResponse]) error {
   324  	return connect.NewError(connect.CodeUnimplemented, errors.New("filesystem.Filesystem.WatchDir is not implemented"))
   325  }
   326  
   327  func (UnimplementedFilesystemHandler) CreateWatcher(context.Context, *connect.Request[filesystem.CreateWatcherRequest]) (*connect.Response[filesystem.CreateWatcherResponse], error) {
   328  	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("filesystem.Filesystem.CreateWatcher is not implemented"))
   329  }
   330  
   331  func (UnimplementedFilesystemHandler) GetWatcherEvents(context.Context, *connect.Request[filesystem.GetWatcherEventsRequest]) (*connect.Response[filesystem.GetWatcherEventsResponse], error) {
   332  	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("filesystem.Filesystem.GetWatcherEvents is not implemented"))
   333  }
   334  
   335  func (UnimplementedFilesystemHandler) RemoveWatcher(context.Context, *connect.Request[filesystem.RemoveWatcherRequest]) (*connect.Response[filesystem.RemoveWatcherResponse], error) {
   336  	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("filesystem.Filesystem.RemoveWatcher is not implemented"))
   337  }