gRPC-web proxy (#8077)

* init

* WIP config

* WIP add proxy server

* fmt

* WIP

* setup proxy server

* clean go.mod

* lint

* lint

* lint

* custom codec

* lint

* add comments

* change grpc-proxy port

* add grpc-web

* update server/start.go

* add tests

* add test with client

* Update server/start.go

Co-authored-by: Anil Kumar Kammari <anil@vitwit.com>

* Update server/start.go

Co-authored-by: Amaury <amaury.martiny@protonmail.com>

* Update server/start.go

Co-authored-by: Amaury <amaury.martiny@protonmail.com>

* review changes

* review changes

* Update server/start.go

Co-authored-by: Anil Kumar Kammari <anil@vitwit.com>
Co-authored-by: Amaury <amaury.martiny@protonmail.com>
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
MD Aleem
2021-01-18 18:25:22 +00:00
committed by GitHub
co-authored by Anil Kumar Kammari Amaury Aleksandr Bezobchuk mergify[bot]
parent 01eec66d28
commit b771effc6c
9 changed files with 438 additions and 7 deletions
+22 -1
View File
@@ -14,8 +14,11 @@ import (
const (
defaultMinGasPrices = ""
// DefaultGRPCAddress is the default address the gRPC server binds to.
// DefaultGRPCAddress defines the default address to bind the gRPC server to.
DefaultGRPCAddress = "0.0.0.0:9090"
// DefaultGRPCWebAddress defines the default address to bind the gRPC-web server to.
DefaultGRPCWebAddress = "0.0.0.0:9091"
)
// BaseConfig defines the server's basic configuration
@@ -107,6 +110,15 @@ type GRPCConfig struct {
Address string `mapstructure:"address"`
}
// GRPCWebConfig defines configuration for the gRPC-web server.
type GRPCWebConfig struct {
// Enable defines if the gRPC-web should be enabled.
Enable bool `mapstructure:"enable"`
// Address defines the gRPC-web server to listen on
Address string `mapstructure:"address"`
}
// StateSyncConfig defines the state sync snapshot configuration.
type StateSyncConfig struct {
// SnapshotInterval sets the interval at which state sync snapshots are taken.
@@ -126,6 +138,7 @@ type Config struct {
Telemetry telemetry.Config `mapstructure:"telemetry"`
API APIConfig `mapstructure:"api"`
GRPC GRPCConfig `mapstructure:"grpc"`
GRPCWeb GRPCWebConfig `mapstructure:"grpc-web"`
StateSync StateSyncConfig `mapstructure:"state-sync"`
}
@@ -185,6 +198,10 @@ func DefaultConfig() *Config {
Enable: true,
Address: DefaultGRPCAddress,
},
GRPCWeb: GRPCWebConfig{
Enable: true,
Address: DefaultGRPCWebAddress,
},
StateSync: StateSyncConfig{
SnapshotInterval: 0,
SnapshotKeepRecent: 2,
@@ -239,6 +256,10 @@ func GetConfig(v *viper.Viper) Config {
Enable: v.GetBool("grpc.enable"),
Address: v.GetString("grpc.address"),
},
GRPCWeb: GRPCWebConfig{
Enable: v.GetBool("grpc-web.enable"),
Address: v.GetString("grpc-web.address"),
},
StateSync: StateSyncConfig{
SnapshotInterval: v.GetUint64("state-sync.snapshot-interval"),
SnapshotKeepRecent: v.GetUint32("state-sync.snapshot-keep-recent"),
+13
View File
@@ -147,6 +147,19 @@ enable = {{ .GRPC.Enable }}
# Address defines the gRPC server address to bind to.
address = "{{ .GRPC.Address }}"
###############################################################################
### gRPC Web Configuration ###
###############################################################################
[grpc-web]
# GRPCWebEnable defines if the gRPC-web should be enabled.
# NOTE: gRPC must also be enabled, otherwise, this configuration is a no-op.
enable = {{ .GRPCWeb.Enable }}
# Address defines the gRPC-web server address to bind to.
address = "{{ .GRPCWeb.Address }}"
###############################################################################
### State Sync Configuration ###
###############################################################################