Skip to content

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

@flearc

Description

@flearc

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions