Compare commits
3 commits
master
...
grpc-call-
Author | SHA1 | Date | |
---|---|---|---|
3893ca67ac | |||
88789d5f4a | |||
af7db13d51 |
4 changed files with 56 additions and 6 deletions
|
@ -36,7 +36,10 @@ repos:
|
|||
types: [go]
|
||||
language: system
|
||||
|
||||
- repo: https://github.com/golangci/golangci-lint
|
||||
rev: v1.60.3
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: golangci-lint
|
||||
- id: make-lint
|
||||
name: Run Make Lint
|
||||
entry: make lint
|
||||
language: system
|
||||
pass_filenames: false
|
||||
|
|
43
Makefile
43
Makefile
|
@ -8,13 +8,18 @@ PROTOC_OS_VERSION=osx-x86_64
|
|||
ifeq ($(shell uname), Linux)
|
||||
PROTOC_OS_VERSION=linux-x86_64
|
||||
endif
|
||||
LINT_VERSION ?= 1.60.3
|
||||
TRUECLOUDLAB_LINT_VERSION ?= 0.0.7
|
||||
|
||||
BIN = bin
|
||||
PROTOBUF_DIR ?= $(abspath $(BIN))/protobuf
|
||||
PROTOC_DIR ?= $(PROTOBUF_DIR)/protoc-v$(PROTOC_VERSION)
|
||||
PROTOC_GEN_GO_DIR ?= $(PROTOBUF_DIR)/protoc-gen-go-$(PROTOC_GEN_GO_VERSION)
|
||||
OUTPUT_LINT_DIR ?= $(abspath $(BIN))/linters
|
||||
LINT_DIR = $(OUTPUT_LINT_DIR)/golangci-lint-$(LINT_VERSION)-v$(TRUECLOUDLAB_LINT_VERSION)
|
||||
TMP_DIR := .cache
|
||||
|
||||
.PHONY: dep fmts fumpt imports protoc test lint version help $(BIN)/protogen protoc-test
|
||||
.PHONY: dep fmts fumpt imports protoc test version help $(BIN)/protogen protoc-test
|
||||
|
||||
# Pull go dependencies
|
||||
dep:
|
||||
|
@ -92,9 +97,43 @@ test:
|
|||
@echo "⇒ Running go test"
|
||||
@GOFLAGS="$(GOFLAGS)" go test ./...
|
||||
|
||||
|
||||
.PHONY: lint-install lint
|
||||
|
||||
# Install linters
|
||||
lint-install:
|
||||
@rm -rf $(OUTPUT_LINT_DIR)
|
||||
@mkdir $(OUTPUT_LINT_DIR)
|
||||
@mkdir -p $(TMP_DIR)
|
||||
@rm -rf $(TMP_DIR)/linters
|
||||
@git -c advice.detachedHead=false clone --branch v$(TRUECLOUDLAB_LINT_VERSION) https://git.frostfs.info/TrueCloudLab/linters.git $(TMP_DIR)/linters
|
||||
@@make -C $(TMP_DIR)/linters lib CGO_ENABLED=1 OUT_DIR=$(OUTPUT_LINT_DIR)
|
||||
@rm -rf $(TMP_DIR)/linters
|
||||
@rmdir $(TMP_DIR) 2>/dev/null || true
|
||||
@CGO_ENABLED=1 GOBIN=$(LINT_DIR) go install -trimpath github.com/golangci/golangci-lint/cmd/golangci-lint@v$(LINT_VERSION)
|
||||
|
||||
# Run linters
|
||||
lint:
|
||||
@golangci-lint run
|
||||
@if [ ! -d "$(LINT_DIR)" ]; then \
|
||||
make lint-install; \
|
||||
fi
|
||||
$(LINT_DIR)/golangci-lint run
|
||||
|
||||
|
||||
.PHONY: pre-commit unpre-commit pre-commit-run
|
||||
|
||||
# Activate pre-commit hooks
|
||||
pre-commit:
|
||||
pre-commit install --hook-type pre-commit
|
||||
|
||||
# Deactivate pre-commit hooks
|
||||
unpre-commit:
|
||||
pre-commit uninstall --hook-type pre-commit
|
||||
|
||||
# Run pre-commit hooks
|
||||
pre-commit-run:
|
||||
@pre-commit run --all-files --hook-stage manual
|
||||
|
||||
|
||||
# Print version
|
||||
version:
|
||||
|
|
|
@ -55,7 +55,7 @@ func (c *Client) Init(info common.CallMethodInfo, opts ...CallOption) (MessageRe
|
|||
StreamName: info.Name,
|
||||
ServerStreams: info.ServerStream(),
|
||||
ClientStreams: info.ClientStream(),
|
||||
}, toMethodName(info))
|
||||
}, toMethodName(info), c.grpcCallOpts...)
|
||||
if err != nil {
|
||||
cancel()
|
||||
return nil, err
|
||||
|
|
|
@ -24,6 +24,7 @@ type cfg struct {
|
|||
|
||||
tlsCfg *tls.Config
|
||||
grpcDialOpts []grpc.DialOption
|
||||
grpcCallOpts []grpc.CallOption
|
||||
|
||||
conn Conn
|
||||
}
|
||||
|
@ -127,3 +128,10 @@ func WithGRPCDialOptions(opts []grpc.DialOption) Option {
|
|||
c.grpcDialOpts = append(c.grpcDialOpts, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
// WithGRPCDialOptions returns an option to specify grpc.Call.
|
||||
func WithGRPCCallOptions(opts []grpc.CallOption) Option {
|
||||
return func(c *cfg) {
|
||||
c.grpcCallOpts = append(c.grpcCallOpts, opts...)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue