Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 41 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,44 @@
########################################################
########################################################
########################################################
########################################################

# Scripts Related to developing Blobber

########################################################
########################################################
########################################################
########################################################


.PHONY: test
test:
go test ./...;

.PHONY: lint
lint:
golangci-lint run --timeout 2m0s;

.PHONY: integration-tests
integration-tests:
sudo go test ./... -args integration;




########################################################
########################################################
########################################################
########################################################

# Scripts related to setting up Buf

########################################################
########################################################
########################################################
########################################################


SHELL := /usr/bin/env bash -o pipefail

# This controls the location of the cache.
Expand Down Expand Up @@ -116,14 +157,3 @@ else
sed -i "s/BUF_VERSION := [0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*/BUF_VERSION := $(VERSION)/g" Makefile
endif
endif

.PHONY: test lint integration-tests

test:
go test ./...;

lint:
golangci-lint run --timeout 2m0s;

integration-tests:
sudo go test ./... -args integration;
33 changes: 14 additions & 19 deletions code/go/0chain.net/blobbercore/blobbergrpc/README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
# GRPC Endpoints

## Development

Modify the '.proto' file in `code/go/0chain.net/blobbercore/blobbergrpc/proto/blobber.proto` and run
`scripts/generate-grpc.sh` to add new api's.

GRPC API is implemented in `code/go/0chain.net/blobbercore/handler/grpc_handler.go`.

## Installation

Install the [protoc](https://grpc.io/docs/protoc-installation/) command line interface.
We are using Buf, which is building a better way to work with Protocol Buffers. Buf supports
linting & detecting breaking changes for our gRPC protos as well as generating the gRPC stubs.

### Pre-Requisites
- Setup [Buf](https://buf.build) tool on local, run
```sh
make deps
```
- Installation of required go-deps for gRPC, run
```sh
go install \
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway \
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 \
google.golang.org/protobuf/cmd/protoc-gen-go \
google.golang.org/grpc/cmd/protoc-gen-go-grpc
```

Run this command to install all the GRPC related binaries required to generate GRPC related files using `protoc` CLI.
## Development

Now you can run the script in `scripts/generate-grpc.sh`.
- All the protos present in the project can be found by `buf ls-files`.

## Plugins
- Generation of stubs on local can be done by ` buf generate -o ./code/go/0chain.net/blobbercore/blobbergrpc/`

* [grpc-gateway](https://github.com/grpc-ecosystem/grpc-gateway)
plugin is being used to expose a REST api for grpc incompatible clients.
- Buf is also capable of linting the protos according to the best practices of the gRPC `buf lint`

## Testing

Expand All @@ -36,12 +33,10 @@ to use docker network ip and not localhost.

Make sure the server is running on `--deployment_mode 0` to use server reflection.

You can use https://github.com/vektra/mockery to generate mocks for tests.

## Documentation

Basic documentation can be found here - https://grpc.io/docs/languages/go/basics/.
The basic documentation can be found here - https://grpc.io/docs/languages/go/basics/.

Advanced documentation can be found here - https://github.com/grpc/grpc-go/tree/master/Documentation.
The advanced documentation can be found here - https://github.com/grpc/grpc-go/tree/master/Documentation.


3 changes: 0 additions & 3 deletions scripts/generate-grpc.sh

This file was deleted.