add grpc server support

This commit is contained in:
yanghao05
2023-05-06 15:29:16 +08:00
parent 3a9a1a6eeb
commit 4964b59b2c
9 changed files with 156 additions and 35 deletions

30
providers/grpcs/config.go Normal file
View File

@@ -0,0 +1,30 @@
package grpcs
import (
"fmt"
)
const DefaultPrefix = "Grpc"
type Config struct {
Host *string
Port uint
Tls *Tls
}
type Tls struct {
CA string
Cert string
Key string
}
func (h *Config) Address() string {
if h.Host == nil {
return h.PortString()
}
return fmt.Sprintf("%s:%d", *h.Host, h.Port)
}
func (h *Config) PortString() string {
return fmt.Sprintf(":%d", h.Port)
}