Skip to content

Commit

Permalink
Merge branch 'release/0.2.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeniy Kulikov committed Dec 17, 2019
2 parents 3fc1c74 + 13bc423 commit 96e38dd
Show file tree
Hide file tree
Showing 7 changed files with 655 additions and 27 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changelog
This is the changelog for NeoFS Proto

## [0.2.6] - 2019-12-17

### Added
- Request to dump node config

## [0.2.5] - 2019-12-05

### Removed
Expand Down Expand Up @@ -66,3 +71,4 @@ Initial public release
[0.2.3]: https://github.com/nspcc-dev/neofs-proto/compare/v0.2.2...v0.2.3
[0.2.4]: https://github.com/nspcc-dev/neofs-proto/compare/v0.2.3...v0.2.4
[0.2.5]: https://github.com/nspcc-dev/neofs-proto/compare/v0.2.4...v0.2.5
[0.2.6]: https://github.com/nspcc-dev/neofs-proto/compare/v0.2.5...v0.2.6
36 changes: 36 additions & 0 deletions docs/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
- [Status](#state.Status)

- Messages
- [DumpRequest](#state.DumpRequest)
- [DumpResponse](#state.DumpResponse)
- [HealthRequest](#state.HealthRequest)
- [HealthResponse](#state.HealthResponse)
- [MetricsRequest](#state.MetricsRequest)
Expand Down Expand Up @@ -36,6 +38,7 @@ Status service provides node's healthcheck and status info
rpc Netmap(NetmapRequest) returns (.bootstrap.SpreadMap);
rpc Metrics(MetricsRequest) returns (MetricsResponse);
rpc HealthCheck(HealthRequest) returns (HealthResponse);
rpc DumpConfig(DumpRequest) returns (DumpResponse);
```

Expand All @@ -61,9 +64,42 @@ If node unhealthy field Status would contains detailed info.
| Name | Input | Output |
| ---- | ----- | ------ |
| HealthCheck | [HealthRequest](#state.HealthRequest) | [HealthResponse](#state.HealthResponse) |
#### Method DumpConfig

DumpConfig request allows dumping settings for the current node.
To permit access, used server config options.
The request should be signed.

| Name | Input | Output |
| ---- | ----- | ------ |
| DumpConfig | [DumpRequest](#state.DumpRequest) | [DumpResponse](#state.DumpResponse) |
<!-- end services -->


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

### Message DumpRequest
DumpRequest message to fetch current server config.


| 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.DumpResponse"></a>

### Message DumpResponse
DumpResponse message contains current server config.
Config stored in JSON encoded into slice of bytes.


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


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

### Message HealthRequest
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ require (
github.com/pkg/errors v0.8.1
github.com/prometheus/client_golang v1.2.1
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4
github.com/spf13/viper v1.6.1
github.com/stretchr/testify v1.4.0
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550
google.golang.org/grpc v1.24.0
Expand Down
96 changes: 96 additions & 0 deletions go.sum

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions state/service.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package state

import (
"encoding/json"

"github.com/golang/protobuf/proto"
"github.com/prometheus/client_golang/prometheus"
dto "github.com/prometheus/client_model/go"
"github.com/spf13/viper"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
Expand Down Expand Up @@ -46,3 +49,14 @@ func DecodeMetrics(r *MetricsResponse) ([]*MetricFamily, error) {

return metrics, nil
}

// EncodeConfig encodes viper settings into DumpConfig message,
// if something went wrong returns gRPC Status error (can be returned from service).
func EncodeConfig(v *viper.Viper) (*DumpResponse, error) {
data, err := json.Marshal(v.AllSettings())
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}

return &DumpResponse{Config: data}, nil
}
Loading

0 comments on commit 96e38dd

Please sign in to comment.