Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functions' and fields' visibility should be the same with sentinel-golang #147

Open
flearc opened this issue Apr 12, 2024 · 0 comments
Open

Comments

@flearc
Copy link
Contributor

flearc commented Apr 12, 2024

Compared to sentinel-golang, some functions and struct fields have different visibility in sentinel-rust.

For example, form_metric_filename in golang is public but in rust it is private.

    // Generate the metric file name from the service name.
    func FormMetricFileName(serviceName string, withPid bool) string {
	dot := "."
	separator := "-"
	if strings.Contains(serviceName, dot) {
		serviceName = strings.ReplaceAll(serviceName, dot, separator)
	}
	filename := serviceName + separator + MetricFileNameSuffix
	if withPid {
		pid := os.Getpid()
		filename = filename + ".pid" + strconv.Itoa(pid)
	}
	return filename
}
// Generate the metric file name from the service name.
fn form_metric_filename(service_name: &str, with_pid: bool) -> String {
    let separator = "-";
    let mut filename = if service_name.contains('.') {
        service_name.replace('.', separator)
    } else {
        service_name.to_string()
    };

    filename.push_str(&format!("{}{}", separator, METRIC_FILENAME_SUFFIX));

    if with_pid {
        let pid = std::process::id();
        filename.push_str(&format!(".pid{}", pid));
    }

    filename
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant