[PR #1138] [MERGED] Add GRPC Api #1227

Closed
opened 2026-03-03 12:33:38 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/fsouza/fake-gcs-server/pull/1138
Author: @RachitSharma2001
Created: 4/22/2023
Status: Merged
Merged: 5/9/2023
Merged by: @fsouza

Base: mainHead: main


📝 Commits (6)

📊 Changes

13 files changed (+14528 additions, -38 deletions)

View changed files

📝 fakestorage/bucket.go (+8 -8)
📝 fakestorage/object.go (+11 -11)
📝 fakestorage/server.go (+10 -5)
📝 fakestorage/server_test.go (+20 -2)
📝 fakestorage/upload.go (+1 -1)
genproto/googleapis/storage/v1/storage.pb.go (+9341 -0)
genproto/googleapis/storage/v1/storage_resources.pb.go (+4610 -0)
📝 go.mod (+6 -5)
📝 go.sum (+3 -0)
grpc/server.go (+178 -0)
grpc/server_test.go (+314 -0)
📝 internal/config/config.go (+1 -0)
📝 main.go (+25 -6)

📄 Description

Addresses issue #146

Here are the list of changes made:

  • In main.go, both an HTTP and a GRPC listener are set up on the same port using cmux. Then the HTTP and GRPC servers are set up from these listeners.
  • In server.go, the method NewServerWithOptionsOnCmux is invoked by main.go, in order to set up an HTTP server
  • A grpc folder is created, with code that sets up the GRPC server and sets up all the necessary API endpoints, matching the endpoints offered by the Storage interface in internal/backend/storage.go
  • The genproto folder contain the storage.pb.go and storage_resources.pb.go files.

Let me know if there is anything concerning or anything that should change. It seems like all the unit and end to end tests succeed, so it looks like both Http and Grpc requests can now be made.

I also had created a script that makes GRPC requests to the server using GRPCurl:

#!/bin/bash
cd real-gcs-grpc
docker build -t fake-server-grpc . 
img_id=$(docker run -d --name fake-gcs-server -p 4443:4443 -p 5000:5000 -v ${PWD}/all_files:/data fake-server-grpc)

echo "Creating new bucket with grpc:"
grpcurl -d '{"bucket": {"name" : "bucket49"}}' -plaintext localhost:4443 google.storage.v1.StorageServer.InsertBucket 

# echo "Listing Buckets with Http: "
# curl -k "https://localhost:4443/storage/v1/b"

echo "Grp curl on get bucket:" 
grpcurl -d '{"bucket": "bucket49"}' -plaintext localhost:4443 google.storage.v1.StorageServer.GetBucket 

echo "Docker logs:"
docker logs $img_id 

docker rm -f $img_id

The output:

Creating new bucket with grpc:
{

}
Grp curl on get bucket:
{
  "timeCreated": "2023-04-22T18:35:36.214447900Z",
  "id": "bucket49",
  "name": "bucket49",
  "versioning": {

  }
}

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/fsouza/fake-gcs-server/pull/1138 **Author:** [@RachitSharma2001](https://github.com/RachitSharma2001) **Created:** 4/22/2023 **Status:** ✅ Merged **Merged:** 5/9/2023 **Merged by:** [@fsouza](https://github.com/fsouza) **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (6) - [`ed50c5c`](https://github.com/fsouza/fake-gcs-server/commit/ed50c5cbc4cb4cfbe0a43b5da4a249bab1f9ac1a) Add GRPC Api - [`044df61`](https://github.com/fsouza/fake-gcs-server/commit/044df61e8d1f36ee1d54628cb56409a81a6657c3) Fix Server error - [`ddefedf`](https://github.com/fsouza/fake-gcs-server/commit/ddefedf6964b2760cde0e01c01f6577789d07303) Remove duplication in NewServerWithOptions - [`a78d9c2`](https://github.com/fsouza/fake-gcs-server/commit/a78d9c2b563ef26f1dda5b95c355fb22bf8aefdf) Add code format fix - [`f2e0725`](https://github.com/fsouza/fake-gcs-server/commit/f2e072532c9b675b1ee4e55502007eb2b879c942) Merge branch 'main' into main - [`5c70f9c`](https://github.com/fsouza/fake-gcs-server/commit/5c70f9cbc928dd762b4fab184f881c8f6280aef1) Update go mod ### 📊 Changes **13 files changed** (+14528 additions, -38 deletions) <details> <summary>View changed files</summary> 📝 `fakestorage/bucket.go` (+8 -8) 📝 `fakestorage/object.go` (+11 -11) 📝 `fakestorage/server.go` (+10 -5) 📝 `fakestorage/server_test.go` (+20 -2) 📝 `fakestorage/upload.go` (+1 -1) ➕ `genproto/googleapis/storage/v1/storage.pb.go` (+9341 -0) ➕ `genproto/googleapis/storage/v1/storage_resources.pb.go` (+4610 -0) 📝 `go.mod` (+6 -5) 📝 `go.sum` (+3 -0) ➕ `grpc/server.go` (+178 -0) ➕ `grpc/server_test.go` (+314 -0) 📝 `internal/config/config.go` (+1 -0) 📝 `main.go` (+25 -6) </details> ### 📄 Description Addresses issue #146 Here are the list of changes made: - In main.go, both an HTTP and a GRPC listener are set up on the same port using [cmux](https://github.com/soheilhy/cmux). Then the HTTP and GRPC servers are set up from these listeners. - In `server.go`, the method `NewServerWithOptionsOnCmux` is invoked by `main.go`, in order to set up an HTTP server - A grpc folder is created, with code that sets up the GRPC server and sets up all the necessary API endpoints, matching the endpoints offered by the Storage interface in` internal/backend/storage.go` - The genproto folder contain the `storage.pb.go` and `storage_resources.pb.go` files. Let me know if there is anything concerning or anything that should change. It seems like all the unit and end to end tests succeed, so it looks like both Http and Grpc requests can now be made. I also had created a script that makes GRPC requests to the server using GRPCurl: ``` #!/bin/bash cd real-gcs-grpc docker build -t fake-server-grpc . img_id=$(docker run -d --name fake-gcs-server -p 4443:4443 -p 5000:5000 -v ${PWD}/all_files:/data fake-server-grpc) echo "Creating new bucket with grpc:" grpcurl -d '{"bucket": {"name" : "bucket49"}}' -plaintext localhost:4443 google.storage.v1.StorageServer.InsertBucket # echo "Listing Buckets with Http: " # curl -k "https://localhost:4443/storage/v1/b" echo "Grp curl on get bucket:" grpcurl -d '{"bucket": "bucket49"}' -plaintext localhost:4443 google.storage.v1.StorageServer.GetBucket echo "Docker logs:" docker logs $img_id docker rm -f $img_id ``` The output: ``` Creating new bucket with grpc: { } Grp curl on get bucket: { "timeCreated": "2023-04-22T18:35:36.214447900Z", "id": "bucket49", "name": "bucket49", "versioning": { } } ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-03 12:33:38 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/fake-gcs-server#1227
No description provided.