MCPcopy Create free account
hub / github.com/encodeous/nylon / checkMatchLocked

Method checkMatchLocked

e2e/logging.go:85–113  ·  view source on GitHub ↗
(key sourceKey)

Source from the content-addressed store, hash-verified

83}
84
85func (m *LogManager) checkMatchLocked(key sourceKey) {
86 sub, ok := m.subscribers[key]
87 if !ok {
88 return
89 }
90
91 history := m.histories[key]
92 for i, event := range history {
93 matched := false
94 if sub.Regex != nil {
95 if sub.Regex.MatchString(event.Content) {
96 matched = true
97 }
98 } else if sub.Pattern != "" {
99 if strings.Contains(event.Content, sub.Pattern) {
100 matched = true
101 }
102 }
103
104 if matched {
105 m.histories[key] = history[i+1:]
106 select {
107 case sub.MatchCh <- struct{}{}:
108 default:
109 }
110 return
111 }
112 }
113}
114
115func (m *LogManager) Subscribe(node string, source LogSource, pattern string, isRegex bool) (*LogSubscription, error) {
116 m.mu.Lock()

Callers 2

AcceptMethod · 0.95
SubscribeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected