Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Commit

Permalink
feat(api): add file server definition
Browse files Browse the repository at this point in the history
  • Loading branch information
mjpitz committed Sep 13, 2021
1 parent 55d0fdd commit b7e562f
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/commands/daemons/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
agentv1 "github.com/mjpitz/aetherfs/api/aetherfs/agent/v1"
blockv1 "github.com/mjpitz/aetherfs/api/aetherfs/block/v1"
datasetv1 "github.com/mjpitz/aetherfs/api/aetherfs/dataset/v1"
fsv1 "github.com/mjpitz/aetherfs/api/aetherfs/fs/v1"
"github.com/mjpitz/aetherfs/internal/components"
"github.com/mjpitz/aetherfs/internal/flagset"
)
Expand Down Expand Up @@ -64,17 +65,23 @@ func Agent() *cli.Command {
}

agentSvc := &agentService{
blockAPI: blockv1.NewBlockAPIClient(serverConn),
blockAPI: blockv1.NewBlockAPIClient(agentConn),
datasetAPI: datasetv1.NewDatasetAPIClient(serverConn),
}
blockSvc := &blockService{}
fileServerSvc := &fileServerService{}

// setup grpc
grpcServer := components.GRPCServer(ctx.Context, cfg.GRPCServerConfig)
agentv1.RegisterAgentAPIServer(grpcServer, agentSvc)
blockv1.RegisterBlockAPIServer(grpcServer, blockSvc)
fsv1.RegisterFileServerAPIServer(grpcServer, fileServerSvc)

// setup api routes
apiServer := runtime.NewServeMux()
_ = agentv1.RegisterAgentAPIHandler(ctx.Context, apiServer, agentConn)
_ = blockv1.RegisterBlockAPIHandler(ctx.Context, apiServer, agentConn)
_ = fsv1.RegisterFileServerAPIHandler(ctx.Context, apiServer, agentConn)

// prepopulate metrics
grpc_prometheus.Register(grpcServer)
Expand Down
23 changes: 23 additions & 0 deletions internal/commands/daemons/fileserver_service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package daemons

import (
"context"

"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

fsv1 "github.com/mjpitz/aetherfs/api/aetherfs/fs/v1"
)

type fileServerService struct {
fsv1.UnsafeFileServerAPIServer
}

func (f *fileServerService) Lookup(ctx context.Context, request *fsv1.LookupRequest) (*fsv1.LookupResponse, error) {
// parse path
request.GetPath()

return nil, status.Errorf(codes.Unimplemented, "unimplemented")
}

var _ fsv1.FileServerAPIServer = &fileServerService{}
4 changes: 4 additions & 0 deletions internal/commands/daemons/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

blockv1 "github.com/mjpitz/aetherfs/api/aetherfs/block/v1"
datasetv1 "github.com/mjpitz/aetherfs/api/aetherfs/dataset/v1"
fsv1 "github.com/mjpitz/aetherfs/api/aetherfs/fs/v1"
"github.com/mjpitz/aetherfs/internal/components"
"github.com/mjpitz/aetherfs/internal/flagset"
)
Expand Down Expand Up @@ -54,16 +55,19 @@ func Server() *cli.Command {

blockSvc := &blockService{}
datasetSvc := &datasetService{}
fileServerSvc := &fileServerService{}

// setup grpc
grpcServer := components.GRPCServer(ctx.Context, cfg.GRPCServerConfig)
blockv1.RegisterBlockAPIServer(grpcServer, blockSvc)
datasetv1.RegisterDatasetAPIServer(grpcServer, datasetSvc)
fsv1.RegisterFileServerAPIServer(grpcServer, fileServerSvc)

// setup api routes
apiServer := runtime.NewServeMux()
_ = blockv1.RegisterBlockAPIHandler(ctx.Context, apiServer, serverConn)
_ = datasetv1.RegisterDatasetAPIHandler(ctx.Context, apiServer, serverConn)
_ = fsv1.RegisterFileServerAPIHandler(ctx.Context, apiServer, serverConn)

// prepopulate metrics
grpc_prometheus.Register(grpcServer)
Expand Down
39 changes: 39 additions & 0 deletions proto/aetherfs/fs/v1/api.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (C) The AetherFS Authors - All Rights Reserved
//
// Proprietary and confidential.
// Unauthorized copying of this file, via any medium is strictly prohibited.
// Written by Mya Pitzeruse, September 2021

syntax = "proto3";

package aetherfs.fs.v1;

import "google/api/annotations.proto";

option csharp_namespace = "AetherFS.FS.V1";
option go_package = "github.com/mjpitz/aetherfs/api/aetherfs/fs/v1;fsv1";
option java_package = "tech.aetherfs.fs.v1";
option java_outer_classname = "APIProto";
option java_generate_equals_and_hash = true;
option java_multiple_files = true;

message StringList {
repeated string values = 1;
}

message LookupRequest {
string path = 1;
}

message LookupResponse {
string body = 1;
}

service FileServerAPI {
rpc Lookup(LookupRequest) returns (LookupResponse) {
option (google.api.http) = {
get: "/v1/fs/{path=**}"
response_body: "body"
};
}
}

0 comments on commit b7e562f

Please sign in to comment.