Skip to content

Commit

Permalink
Merge branch 'release/0.3.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeniy Kulikov committed Feb 10, 2020
2 parents 928af72 + d5bf805 commit 7f30447
Show file tree
Hide file tree
Showing 7 changed files with 702 additions and 32 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# Changelog
This is the changelog for NeoFS Proto

## [0.3.2] - 2020-02-10

### Added
- gRPC method DumpVars to State service
- add method `EncodeVariables` to encode debug variables to JSON (slice of bytes)
- increase test coverage for state package

### Updated
- state proto file
- documentation for state service and messages

## [0.3.1] - 2020-02-07
### Fixed
- bug with `tz.Concat`
Expand Down Expand Up @@ -177,3 +188,4 @@ Initial public release
[0.2.14]: https://github.com/nspcc-dev/neofs-api/compare/v0.2.13...v0.2.14
[0.3.0]: https://github.com/nspcc-dev/neofs-api/compare/v0.2.14...v0.3.0
[0.3.1]: https://github.com/nspcc-dev/neofs-api/compare/v0.3.0...v0.3.1
[0.3.2]: https://github.com/nspcc-dev/neofs-api/compare/v0.3.1...v0.3.2
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ deps:
@go mod vendor

@echo "${B}${G}=> Cleanup old files ${R}"
@find . -type f -name '*.pb.go' -not -path './vendor/*' -exec rm {} \;
@find . -type f -name '*.proto' -not -path './vendor/*' -not -name '*_test.proto' -exec rm {} \;

@echo "${B}${G}=> NeoFS Proto files ${R}"
Expand Down Expand Up @@ -49,6 +48,9 @@ docgen: deps

# Regenerate proto files:
protoc: deps
@echo "${B}${G}=> Cleanup old files ${R}"
@find . -type f -name '*.pb.go' -not -path './vendor/*' -exec rm {} \;

@echo "${B}${G}=> Install specific version for gogo-proto ${R}"
@go list -f '{{.Path}}/...@{{.Version}}' -m github.com/gogo/protobuf | xargs go get -v
@echo "${B}${G}=> Install specific version for protobuf lib ${R}"
Expand All @@ -60,3 +62,5 @@ protoc: deps
--proto_path=.:./vendor:/usr/local/include \
--gofast_out=plugins=grpc,paths=source_relative:. $$f; \
done

update: docgen protoc
36 changes: 36 additions & 0 deletions docs/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
- Messages
- [DumpRequest](#state.DumpRequest)
- [DumpResponse](#state.DumpResponse)
- [DumpVarsRequest](#state.DumpVarsRequest)
- [DumpVarsResponse](#state.DumpVarsResponse)
- [HealthRequest](#state.HealthRequest)
- [HealthResponse](#state.HealthResponse)
- [MetricsRequest](#state.MetricsRequest)
Expand Down Expand Up @@ -39,6 +41,7 @@ rpc Netmap(NetmapRequest) returns (.bootstrap.SpreadMap);
rpc Metrics(MetricsRequest) returns (MetricsResponse);
rpc HealthCheck(HealthRequest) returns (HealthResponse);
rpc DumpConfig(DumpRequest) returns (DumpResponse);
rpc DumpVars(DumpVarsRequest) returns (DumpVarsResponse);
```

Expand Down Expand Up @@ -73,6 +76,15 @@ The request should be signed.
| Name | Input | Output |
| ---- | ----- | ------ |
| DumpConfig | [DumpRequest](#state.DumpRequest) | [DumpResponse](#state.DumpResponse) |
#### Method DumpVars

DumpVars returns debug variables for the current node.
To permit access, used server config options.
The request should be signed.

| Name | Input | Output |
| ---- | ----- | ------ |
| DumpVars | [DumpVarsRequest](#state.DumpVarsRequest) | [DumpVarsResponse](#state.DumpVarsResponse) |
<!-- end services -->


Expand Down Expand Up @@ -100,6 +112,30 @@ Config stored in JSON encoded into slice of bytes.
| Config | [bytes](#bytes) | | |


<a name="state.DumpVarsRequest"></a>

### Message DumpVarsRequest
DumpVarsRequest message to fetch current server debug variables.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| Meta | [service.RequestMetaHeader](#service.RequestMetaHeader) | | RequestMetaHeader contains information about request meta headers (should be embedded into message) |
| Verify | [service.RequestVerificationHeader](#service.RequestVerificationHeader) | | RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) |


<a name="state.DumpVarsResponse"></a>

### Message DumpVarsResponse
DumpVarsResponse message contains current server debug variables.
Variables stored in JSON encoded into slice of bytes.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| Variables | [bytes](#bytes) | | |


<a name="state.HealthRequest"></a>

### Message HealthRequest
Expand Down
25 changes: 25 additions & 0 deletions state/service.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package state

import (
"bytes"
"encoding/json"
"expvar"
"fmt"

"github.com/golang/protobuf/proto"
"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -61,3 +64,25 @@ func EncodeConfig(v *viper.Viper) (*DumpResponse, error) {

return &DumpResponse{Config: data}, nil
}

// EncodeVariables encodes debug variables into DumpVarsResponse message.
// Variables encoded into JSON and stored as slice of bytes.
func EncodeVariables() *DumpVarsResponse {
buf := new(bytes.Buffer)
buf.WriteString("{\n")
first := true

expvar.Do(func(kv expvar.KeyValue) {
if !first {
buf.WriteString(",\n")
}

first = false

_, _ = fmt.Fprintf(buf, "%q: %s", kv.Key, kv.Value)
})

buf.WriteString("\n}\n")

return &DumpVarsResponse{Variables: buf.Bytes()}
}
Loading

0 comments on commit 7f30447

Please sign in to comment.