io.scalecube.services.ServiceEndpoint Maven / Gradle / Ivy
package io.scalecube.services;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
public class ServiceEndpoint {
private String id;
private String host;
private int port;
private Set contentTypes;
private Map tags;
private Collection serviceRegistrations;
/**
* Constructor for SerDe.
*
* @deprecated exposed only for de/serialization purpose.
*/
public ServiceEndpoint() {}
/**
* Create a service endpoint.
*
* @param id the endpoint's id.
* @param host the endpoint's host.
* @param port the endpoint's port.
* @param tags the endpoint's tags (if any).
* @param serviceRegistrations registration for this endpoint.
*/
public ServiceEndpoint(
String id,
String host,
int port,
Set contentTypes,
Map tags,
Collection serviceRegistrations) {
this.id = id;
this.host = host;
this.port = port;
this.contentTypes = contentTypes;
this.tags = tags;
this.serviceRegistrations = serviceRegistrations;
}
public String id() {
return id;
}
public String host() {
return host;
}
public int port() {
return port;
}
public Set contentTypes() {
return contentTypes;
}
public Map tags() {
return tags;
}
/**
* Return collection of service registratrions.
*
* @return collection of {@link ServiceRegistration}
*/
public Collection serviceRegistrations() {
return serviceRegistrations;
}
/**
* Creates collection of service references from this service endpoint.
*
* @return collection of {@link ServiceReference}
*/
public Collection serviceReferences() {
return serviceRegistrations
.stream()
.flatMap(sr -> sr.methods().stream().map(sm -> new ServiceReference(sm, sr, this)))
.collect(Collectors.toList());
}
@Override
public String toString() {
return "ServiceEndpoint{"
+ "id='"
+ id
+ '\''
+ ", host='"
+ host
+ '\''
+ ", port="
+ port
+ ", tags="
+ tags
+ ", serviceRegistrations="
+ serviceRegistrations
+ '}';
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy