You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1021 B
50 lines
1021 B
package core
|
|
|
|
import (
|
|
"fmt"
|
|
"net/url"
|
|
)
|
|
|
|
const (
|
|
ServiceNode_Tag = "tag"
|
|
ServiceNode_Type = "type"
|
|
ServiceNode_Id = "id"
|
|
ServiceNode_Addr = "addr"
|
|
)
|
|
|
|
func NewServiceNode(value string) (node *ServiceNode, err error) {
|
|
node = &ServiceNode{
|
|
value: value,
|
|
}
|
|
node.meta, err = url.ParseQuery(value)
|
|
return
|
|
}
|
|
|
|
type ServiceNode struct {
|
|
value string
|
|
meta url.Values
|
|
}
|
|
|
|
func (this *ServiceNode) Value() string {
|
|
return this.value
|
|
}
|
|
func (this *ServiceNode) Tag() string {
|
|
return this.meta.Get(ServiceNode_Tag)
|
|
}
|
|
func (this *ServiceNode) Type() string {
|
|
return this.meta.Get(ServiceNode_Type)
|
|
}
|
|
|
|
func (this *ServiceNode) Id() string {
|
|
return this.meta.Get(ServiceNode_Id)
|
|
}
|
|
func (this *ServiceNode) Addr() string {
|
|
return this.meta.Get(ServiceNode_Addr)
|
|
}
|
|
func (this *ServiceNode) Path() string {
|
|
return fmt.Sprintf("%s/%s/%s", this.meta.Get(ServiceNode_Tag), this.meta.Get(ServiceNode_Type), this.meta.Get(ServiceNode_Id))
|
|
}
|
|
|
|
func (this *ServiceNode) Set(key, value string) {
|
|
this.meta.Set(key, value)
|
|
}
|
|
|