diff options
-rw-r--r-- | plugins/grpc/codec.go | 4 | ||||
-rw-r--r-- | plugins/grpc/config.go | 34 | ||||
-rw-r--r-- | plugins/grpc/plugin.go | 32 | ||||
-rw-r--r-- | tests/plugins/grpc/configs/.rr-grpc-init.yaml | 0 |
4 files changed, 67 insertions, 3 deletions
diff --git a/plugins/grpc/codec.go b/plugins/grpc/codec.go index 5938e238..dd299601 100644 --- a/plugins/grpc/codec.go +++ b/plugins/grpc/codec.go @@ -4,9 +4,11 @@ import "google.golang.org/grpc/encoding" type rawMessage []byte +const rm string = "rawMessage" + func (r rawMessage) Reset() {} func (rawMessage) ProtoMessage() {} -func (rawMessage) String() string { return "rawMessage" } +func (rawMessage) String() string { return rm } type codec struct{ base encoding.Codec } diff --git a/plugins/grpc/config.go b/plugins/grpc/config.go new file mode 100644 index 00000000..9a9f8c2c --- /dev/null +++ b/plugins/grpc/config.go @@ -0,0 +1,34 @@ +package grpc + +import ( + "time" + + "github.com/spiral/roadrunner/v2/pkg/pool" +) + +type Config struct { + Listen string `mapstructure:"listen"` + Proto string `mapstructure:"proto"` + + TLS *TLS + + grpcPool pool.Pool + MaxSendMsgSize int64 `mapstructure:"max_send_msg_size"` + MaxRecvMsgSize int64 `mapstructure:"max_recv_msg_size"` + MaxConnectionIdle time.Duration `mapstructure:"max_connection_idle"` + MaxConnectionAge time.Duration `mapstructure:"max_connection_age"` + MaxConnectionAgeGrace time.Duration `mapstructure:"max_connection_age_grace"` + MaxConcurrentStreams int64 `mapstructure:"max_concurrent_streams"` + PingTime time.Duration `mapstructure:"ping_time"` + Timeout time.Duration `mapstructure:"timeout"` +} + +type TLS struct { + Key string + Cert string + RootCA string +} + +func (c *Config) InitDefaults() { + +} diff --git a/plugins/grpc/plugin.go b/plugins/grpc/plugin.go index 5da60d75..fe88dca5 100644 --- a/plugins/grpc/plugin.go +++ b/plugins/grpc/plugin.go @@ -1,11 +1,39 @@ package grpc -import "github.com/spiral/errors" +import ( + "github.com/spiral/errors" + "github.com/spiral/roadrunner/v2/plugins/config" + "github.com/spiral/roadrunner/v2/plugins/logger" +) + +const ( + name string = "grpc" +) type Plugin struct { + cfg config.Configurer + log logger.Logger } -func (p *Plugin) Init() error { +func (p *Plugin) Init(cfg config.Configurer, log logger.Logger) error { const op = errors.Op("grpc_plugin_init") + + return nil +} + +func (p *Plugin) Serve() chan error { + const op = errors.Op("grpc_plugin_serve") + errCh := make(chan error, 1) + + return errCh +} + +func (p *Plugin) Stop() error { return nil } + +func (p *Plugin) Available() {} + +func (p *Plugin) Name() string { + return name +}
\ No newline at end of file diff --git a/tests/plugins/grpc/configs/.rr-grpc-init.yaml b/tests/plugins/grpc/configs/.rr-grpc-init.yaml new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/plugins/grpc/configs/.rr-grpc-init.yaml |