open-consul/agent/consul/system_metadata.go
FFMMM 3c08843847
[sync oss] add net/rpc interceptor implementation (#12573)
* sync ent changes from 866dcb0667

Signed-off-by: FFMMM <FFMMM@users.noreply.github.com>

* update oss go.mod

Signed-off-by: FFMMM <FFMMM@users.noreply.github.com>
2022-03-17 16:02:26 -07:00

42 lines
1 KiB
Go

package consul
import (
"github.com/hashicorp/consul/agent/structs"
)
func (s *Server) getSystemMetadata(key string) (string, error) {
_, entry, err := s.fsm.State().SystemMetadataGet(nil, key)
if err != nil {
return "", err
}
if entry == nil {
return "", nil
}
return entry.Value, nil
}
func (s *Server) setSystemMetadataKey(key, val string) error {
args := &structs.SystemMetadataRequest{
Op: structs.SystemMetadataUpsert,
Entry: &structs.SystemMetadataEntry{Key: key, Value: val},
}
// TODO(rpc-metrics-improv): Double check request name here
_, err := s.leaderRaftApply("SystemMetadata.Upsert", structs.SystemMetadataRequestType, args)
return err
}
func (s *Server) deleteSystemMetadataKey(key string) error {
args := &structs.SystemMetadataRequest{
Op: structs.SystemMetadataDelete,
Entry: &structs.SystemMetadataEntry{Key: key},
}
// TODO(rpc-metrics-improv): Double check request name here
_, err := s.leaderRaftApply("SystemMetadata.Delete", structs.SystemMetadataRequestType, args)
return err
}