/** * Factory method returning Expections with high availabilty and performance requirements. * * @return high expectations */ public static Expectations highExpectations() { return new Expectations(HIGH, Performance.HIGH); }
/** * * @param name The name of the dependent service or datasource * @param description A human readable description of the dependency. * @param type The type of the dependency: db, queue, service, ... * @param subtype The sub-type of the dependency: Cassandra, MongoDB, Kafka, REST, ... * @param criticality Describes the criticality of the dependency for this service. * @param expectations Expectations of this service to the external dependency with respect to availability and performance. */ protected ExternalDependency(final String name, final String description, final String type, final String subtype, final Criticality criticality, final Expectations expectations) { this.name = Objects.toString(name, ""); this.description = Objects.toString(description, ""); this.type = Objects.requireNonNull(type, "Parameter 'type' must not be null"); this.subtype = Objects.requireNonNull(subtype, "Parameter 'subtype' must not be null"); this.criticality = criticality != null ? criticality : unspecifiedCriticality(); this.expectations = expectations != null ? expectations : unspecifiedExpectations(); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ServiceSpec that = (ServiceSpec) o; if (name != null ? !name.equals(that.name) : that.name != null) return false; if (url != null ? !url.equals(that.url) : that.url != null) return false; if (type != null ? !type.equals(that.type) : that.type != null) return false; return !(expectations != null ? !expectations.equals(that.expectations) : that.expectations != null); }
@Override public int hashCode() { int result = name != null ? name.hashCode() : 0; result = 31 * result + (url != null ? url.hashCode() : 0); result = 31 * result + (type != null ? type.hashCode() : 0); result = 31 * result + (expectations != null ? expectations.hashCode() : 0); return result; }
@Bean @ConditionalOnProperty(prefix="edison.serviceregistry", name="enabled", havingValue = "true") public ServiceDependency serviceRegistryDependency() { return ServiceDependencyBuilder.serviceDependency(serviceRegistryProperties.getServers()) .withName("Service Registry") .withDescription("Registers this service at a service registry") .withExpectations(expects(Availability.MEDIUM, Performance.MEDIUM)) .withCriticality(Criticality.criticality(Level.HIGH, "Service cannot be registered")) .build(); }
restServiceDependency("foobar:4711") .withCriticality(criticality(HIGH, "Bad. Really bad.")) .withExpectations(lowExpectations()) .build() ));
public static ServiceSpec serviceSpec(final String name, final String url) { return new ServiceSpec(name, url, unspecifiedService(), unspecifiedExpectations()); }
/** * Factory method returning Expections with given availabilty and performance requirements. * * @param availability the expected availability * @param performance the expected performance * @return Expectations */ public static Expectations expects(final Availability availability, final Performance performance) { return new Expectations(availability, performance); }
private ServiceDependency someRestfulService() { return new ServiceDependency( "shoppingcart", "Imports shoppingcarts", "http://example.com/order/shoppingcarts", TYPE_SERVICE, SUBTYPE_REST, singletonList("GET"), singletonList("application/json"), "OAUTH", criticality(Level.HIGH, "really bad"), unspecifiedExpectations()); } }
/** * Factory method returning Expections with unspecified availabilty and performance requirements. * * @return unspecified expectations */ public static Expectations unspecifiedExpectations() { return new Expectations(NOT_SPECIFIED, Performance.NOT_SPECIFIED); }
/** * Factory method returning Expections with low availabilty and performance requirements. * * @return low expectations */ public static Expectations lowExpectations() { return new Expectations(LOW, Performance.LOW); }
/** * Factory method returning Expections with medium availabilty and performance requirements. * * @return medium expectations */ public static Expectations mediumExpectations() { return new Expectations(MEDIUM, Performance.MEDIUM); }
public static Expectations highExpectations() { return new Expectations(Availability.HIGH, Performance.HIGH); }
public static Expectations unspecifiedExpectations() { return new Expectations(Availability.NOT_SPECIFIED, Performance.NOT_SPECIFIED); }
public static Expectations expects(final Availability availability, final Performance performance) { return new Expectations(availability, performance); }
public static Expectations lowExpectations() { return new Expectations(Availability.LOW, Performance.LOW); }