X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fcontrol%2Ftypes.go;h=164e80167ba8216d3722131a8cf5c06d7a3f83c8;hb=12d31af1cdfcbf5f634d9cf666e8e174c74ecb27;hp=e7403498422d6160a7c54e3cf6c81a68ea77a837;hpb=31797b49985822f1d402501f16ab2794838bebba;p=ric-plt%2Fsubmgr.git diff --git a/pkg/control/types.go b/pkg/control/types.go index e740349..164e801 100644 --- a/pkg/control/types.go +++ b/pkg/control/types.go @@ -91,6 +91,42 @@ func (eplist *RmrEndpointList) String() string { return strings.Join(valuesText, ",") } +func (eplist *RmrEndpointList) Size() int { + return len(eplist.Endpoints) +} + +func (eplist *RmrEndpointList) AddEndpoint(ep *RmrEndpoint) bool { + for i := range eplist.Endpoints { + if (eplist.Endpoints[i].Addr == ep.Addr) && (eplist.Endpoints[i].Port == ep.Port) { + return false + } + } + eplist.Endpoints = append(eplist.Endpoints, *ep) + return true +} + +func (eplist *RmrEndpointList) DelEndpoint(ep *RmrEndpoint) bool { + for i := range eplist.Endpoints { + if (eplist.Endpoints[i].Addr == ep.Addr) && (eplist.Endpoints[i].Port == ep.Port) { + eplist.Endpoints[i] = eplist.Endpoints[len(eplist.Endpoints)-1] + eplist.Endpoints[len(eplist.Endpoints)-1] = RmrEndpoint{"", 0} + eplist.Endpoints = eplist.Endpoints[:len(eplist.Endpoints)-1] + return true + } + } + return false +} + +func (eplist *RmrEndpointList) DelEndpoints(otheplist *RmrEndpointList) bool { + var retval bool = false + for i := range otheplist.Endpoints { + if eplist.DelEndpoint(&eplist.Endpoints[i]) { + retval = true + } + } + return retval +} + func (eplist *RmrEndpointList) HasEndpoint(ep *RmrEndpoint) bool { for i := range eplist.Endpoints { if (eplist.Endpoints[i].Addr == ep.Addr) && (eplist.Endpoints[i].Port == ep.Port) { @@ -116,7 +152,7 @@ type Action int func (act Action) String() string { actions := [...]string{ "CREATE", - "MERGE", + "UPDATE", "NONE", "DELETE", }