mirror of https://github.com/status-im/consul.git
Added support for Service Metadata
This commit is contained in:
parent
2ea47271ce
commit
80dde5465b
|
@ -576,6 +576,11 @@ func (s *HTTPServer) AgentRegisterService(resp http.ResponseWriter, req *http.Re
|
|||
|
||||
// Get the node service.
|
||||
ns := args.NodeService()
|
||||
if err := structs.ValidateMetadata(ns.ServiceMeta, false); err != nil {
|
||||
resp.WriteHeader(http.StatusBadRequest)
|
||||
fmt.Fprint(resp, fmt.Errorf("Invalid Meta: %v", err))
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Verify the check type.
|
||||
chkTypes, err := args.CheckTypes()
|
||||
|
|
|
@ -6,6 +6,7 @@ type ServiceDefinition struct {
|
|||
Name string
|
||||
Tags []string
|
||||
Address string
|
||||
ServiceMeta map[string]string
|
||||
Port int
|
||||
Check CheckType
|
||||
Checks CheckTypes
|
||||
|
@ -19,6 +20,7 @@ func (s *ServiceDefinition) NodeService() *NodeService {
|
|||
Service: s.Name,
|
||||
Tags: s.Tags,
|
||||
Address: s.Address,
|
||||
ServiceMeta: s.ServiceMeta,
|
||||
Port: s.Port,
|
||||
EnableTagOverride: s.EnableTagOverride,
|
||||
}
|
||||
|
|
|
@ -368,6 +368,7 @@ type ServiceNode struct {
|
|||
ServiceName string
|
||||
ServiceTags []string
|
||||
ServiceAddress string
|
||||
ServiceMeta map[string]string
|
||||
ServicePort int
|
||||
ServiceEnableTagOverride bool
|
||||
|
||||
|
@ -390,6 +391,7 @@ func (s *ServiceNode) PartialClone() *ServiceNode {
|
|||
ServiceTags: tags,
|
||||
ServiceAddress: s.ServiceAddress,
|
||||
ServicePort: s.ServicePort,
|
||||
ServiceMeta: s.ServiceMeta,
|
||||
ServiceEnableTagOverride: s.ServiceEnableTagOverride,
|
||||
RaftIndex: RaftIndex{
|
||||
CreateIndex: s.CreateIndex,
|
||||
|
@ -406,6 +408,7 @@ func (s *ServiceNode) ToNodeService() *NodeService {
|
|||
Tags: s.ServiceTags,
|
||||
Address: s.ServiceAddress,
|
||||
Port: s.ServicePort,
|
||||
ServiceMeta: s.ServiceMeta,
|
||||
EnableTagOverride: s.ServiceEnableTagOverride,
|
||||
RaftIndex: RaftIndex{
|
||||
CreateIndex: s.CreateIndex,
|
||||
|
@ -422,6 +425,7 @@ type NodeService struct {
|
|||
Service string
|
||||
Tags []string
|
||||
Address string
|
||||
ServiceMeta map[string]string
|
||||
Port int
|
||||
EnableTagOverride bool
|
||||
|
||||
|
@ -438,6 +442,7 @@ func (s *NodeService) IsSame(other *NodeService) bool {
|
|||
!reflect.DeepEqual(s.Tags, other.Tags) ||
|
||||
s.Address != other.Address ||
|
||||
s.Port != other.Port ||
|
||||
!reflect.DeepEqual(s.ServiceMeta, other.ServiceMeta) ||
|
||||
s.EnableTagOverride != other.EnableTagOverride {
|
||||
return false
|
||||
}
|
||||
|
@ -457,6 +462,7 @@ func (s *NodeService) ToServiceNode(node string) *ServiceNode {
|
|||
ServiceTags: s.Tags,
|
||||
ServiceAddress: s.Address,
|
||||
ServicePort: s.Port,
|
||||
ServiceMeta: s.ServiceMeta,
|
||||
ServiceEnableTagOverride: s.EnableTagOverride,
|
||||
RaftIndex: RaftIndex{
|
||||
CreateIndex: s.CreateIndex,
|
||||
|
|
|
@ -66,6 +66,7 @@ type AgentServiceRegistration struct {
|
|||
Port int `json:",omitempty"`
|
||||
Address string `json:",omitempty"`
|
||||
EnableTagOverride bool `json:",omitempty"`
|
||||
ServiceMeta map[string]string `json:",omitempty"`
|
||||
Check *AgentServiceCheck
|
||||
Checks AgentServiceChecks
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ type CatalogService struct {
|
|||
ServiceName string
|
||||
ServiceAddress string
|
||||
ServiceTags []string
|
||||
ServiceMeta map[string]string
|
||||
ServicePort int
|
||||
ServiceEnableTagOverride bool
|
||||
CreateIndex uint64
|
||||
|
|
Loading…
Reference in New Issue