26 lines
1.0 KiB
Java
26 lines
1.0 KiB
Java
package dev.ltms.bridged.health;
|
|
|
|
import dev.ltms.bridged.msg.Rendezvous;
|
|
|
|
import java.util.Map;
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
/**
|
|
* Counts turns that ended via the completion fallback instead of {@code bridge_reply}.
|
|
* MUTE is an observation by target and profile, not a classifier state and never suppresses faults.
|
|
*/
|
|
public final class MuteCounter {
|
|
private final Map<String, Integer> byTarget = new ConcurrentHashMap<>();
|
|
private final Map<String, Integer> byProfile = new ConcurrentHashMap<>();
|
|
|
|
/** Record only fallback completion; a structured reply does not make a member mute. */
|
|
public void observe(String target, String profile, Rendezvous.Kind kind) {
|
|
if (kind != Rendezvous.Kind.COMPLETION) return;
|
|
byTarget.merge(target, 1, Integer::sum);
|
|
byProfile.merge(profile, 1, Integer::sum);
|
|
}
|
|
|
|
public int forTarget(String target) { return byTarget.getOrDefault(target, 0); }
|
|
public int forProfile(String profile) { return byProfile.getOrDefault(profile, 0); }
|
|
}
|