public void TryParse_should_parse_replica_path( [Values(null, "prefix/node", "/prefix/node", "prefix/node/", "/prefix/node/")] string prefix, [Values("environment", "EEE/eee")] string environment, [Values("application", "AAA/aaa")] string application, [Values("replica", "RRR/rrr")] string replica) { var path = new ServiceDiscoveryPathHelper(prefix, ZooKeeperPathEscaper.Instance); path.TryParse(path.BuildEnvironmentPath(environment)) .Should() .Be(((string environment, string application, string replica)?)(environment?.ToLowerInvariant(), null, null)); path.TryParse(path.BuildApplicationPath(environment, application)) .Should() .Be(((string environment, string application, string replica)?)(environment?.ToLowerInvariant(), application, null)); path.TryParse(path.BuildReplicaPath(environment, application, replica)) .Should() .Be(((string environment, string application, string replica)?)(environment?.ToLowerInvariant(), application, replica)); }
private void OnNodeEvent(NodeChangedEventType type, string path) { if (isDisposed) { return; } var parsedPath = pathHelper.TryParse(path); if (parsedPath?.environment == null || parsedPath.Value.application != null) { log.Warn("Received node event of type '{NodeEventType}' on path '{NodePath}': not an environment node.", type, path); return; } // Note(kungurtsev): run in new thread, because we shouldn't block ZooKeeperClient. eventsHandler.Enqueue(() => Update(parsedPath.Value.environment)); }