Skip to content

Commit

Permalink
Completed the HasTag function logic (#72)
Browse files Browse the repository at this point in the history
Co-authored-by: Mansour B <[email protected]>
  • Loading branch information
mbaitar and mbaitar authored Dec 1, 2023
1 parent af84252 commit 8dac16e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion actor/pid.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package actor

import (
"slices"
"strings"

"github.com/zeebo/xxh3"
Expand Down Expand Up @@ -37,8 +38,13 @@ func (pid *PID) Child(id string, tags ...string) *PID {
return NewPID(pid.Address, childID+pidSeparator+strings.Join(tags, pidSeparator))
}

// HasTag returns whether the provided tag is applied to a pid address or not
func (pid *PID) HasTag(tag string) bool {
return strings.Contains(pid.ID, pidSeparator+tag+pidSeparator)
if len(tag) == 0 {
return false
}
parsedPid := strings.Split(pid.ID, pidSeparator)
return slices.Contains(parsedPid, tag)
}

func (pid *PID) LookupKey() uint64 {
Expand Down

0 comments on commit 8dac16e

Please sign in to comment.