io.scalecube.services.ServiceEndpoint Maven / Gradle / Ivy
package io.scalecube.services;
import io.scalecube.services.transport.api.Address;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
public class ServiceEndpoint {
private String id;
private Address address;
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 address the endpoint's address.
* @param tags the endpoint's tags (if any).
* @param serviceRegistrations registration for this endpoint.
*/
public ServiceEndpoint(
String id,
Address address,
Set contentTypes,
Map tags,
Collection serviceRegistrations) {
this.id = id;
this.address = address;
this.contentTypes = contentTypes;
this.tags = tags;
this.serviceRegistrations = serviceRegistrations;
}
public String id() {
return id;
}
public Address address() {
return address;
}
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
+ '\''
+ ", address='"
+ address
+ '\''
+ ", tags="
+ tags
+ ", serviceRegistrations="
+ serviceRegistrations
+ '}';
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy