summaryrefslogtreecommitdiff
path: root/plugins/grpc/config.go
blob: 8a3af6a247c9c2ace216bb0524f5f59f90f0c444 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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.Config
	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() {

}

func (c *Config) EnableTLS() bool {
	if c.TLS != nil {
		return (c.TLS.RootCA != "" && c.TLS.Key != "" && c.TLS.Cert != "") || (c.TLS.Key != "" && c.TLS.Cert != "")
	}

	return false
}