forked from Silverfish/proton-bridge
Other: Simple gRPC client/server under test
This commit is contained in:
@ -22,15 +22,15 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
// config is a structure containing the service configuration data that are exchanged by the gRPC server and client.
|
||||
type config struct {
|
||||
// Config is a structure containing the service configuration data that are exchanged by the gRPC server and client.
|
||||
type Config struct {
|
||||
Port int `json:"port"`
|
||||
Cert string `json:"cert"`
|
||||
Token string `json:"token"`
|
||||
}
|
||||
|
||||
// save saves a gRPC service configuration to file.
|
||||
func (s *config) save(path string) error {
|
||||
func (s *Config) save(path string) error {
|
||||
// Another process may be waiting for this file to be available. In order to prevent this process to open
|
||||
// the file while we are writing in it, we write it with a temp file name, then rename it.
|
||||
tempPath := path + "_"
|
||||
@ -41,7 +41,7 @@ func (s *config) save(path string) error {
|
||||
return os.Rename(tempPath, path)
|
||||
}
|
||||
|
||||
func (s *config) _save(path string) error {
|
||||
func (s *Config) _save(path string) error {
|
||||
f, err := os.Create(path) //nolint:errcheck,gosec
|
||||
if err != nil {
|
||||
return err
|
||||
@ -53,7 +53,7 @@ func (s *config) _save(path string) error {
|
||||
}
|
||||
|
||||
// load loads a gRPC service configuration from file.
|
||||
func (s *config) load(path string) error {
|
||||
func (s *Config) load(path string) error {
|
||||
f, err := os.Open(path) //nolint:errcheck,gosec
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user