/** * Checks whether or not the current object is equal to the given object. * * @param o the object to compare to this service record * @return {@code true} when equal, {@code false} otherwise */ @Override public boolean equals(Object o) { if (o == this) return true; if (!(o instanceof Record)) return false; Record other = (Record) o; return (name == null ? other.name == null : name.equals(other.name)) && (type == null ? other.type == null : type.equals(other.type)) && (location == null ? other.location == null : location.equals(other.location)) && (metadata == null ? other.metadata == null : metadata.equals(other.metadata)) && (registration == null ? other.registration == null : registration.equals(other.registration)) && (status == null ? other.status == null : status.equals(other.status)); }
/** * @return the hash code of the current service record */ @Override public int hashCode() { int result = 17; result = 31 * result + (name == null ? 0 : name.hashCode()); result = 31 * result + (type == null ? 0 : type.hashCode()); result = 31 * result + (location == null ? 0 : location.hashCode()); result = 31 * result + (metadata == null ? 0 : metadata.hashCode()); result = 31 * result + (registration == null ? 0 : registration.hashCode()); result = 31 * result + (status == null ? 0 : status.hashCode()); return result; } }
public static void toJson(Record obj, java.util.Map<String, Object> json) { if (obj.getLocation() != null) { json.put("location", obj.getLocation()); } if (obj.getMetadata() != null) { json.put("metadata", obj.getMetadata()); } if (obj.getName() != null) { json.put("name", obj.getName()); } if (obj.getRegistration() != null) { json.put("registration", obj.getRegistration()); } if (obj.getStatus() != null) { json.put("status", obj.getStatus().name()); } if (obj.getType() != null) { json.put("type", obj.getType()); } } }
case "status": if (member.getValue() instanceof String) { obj.setStatus(io.vertx.servicediscovery.Status.valueOf((String)member.getValue()));
public static void toJson(Record obj, java.util.Map<String, Object> json) { if (obj.getLocation() != null) { json.put("location", obj.getLocation()); } if (obj.getMetadata() != null) { json.put("metadata", obj.getMetadata()); } if (obj.getName() != null) { json.put("name", obj.getName()); } if (obj.getRegistration() != null) { json.put("registration", obj.getRegistration()); } if (obj.getStatus() != null) { json.put("status", obj.getStatus().name()); } if (obj.getType() != null) { json.put("type", obj.getType()); } } }
case "status": if (member.getValue() instanceof String) { obj.setStatus(io.vertx.servicediscovery.Status.valueOf((String)member.getValue()));
/** * Checks whether or not the current object is equal to the given object. * * @param o the object to compare to this service record * @return {@code true} when equal, {@code false} otherwise */ @Override public boolean equals(Object o) { if (o == this) return true; if (!(o instanceof Record)) return false; Record other = (Record) o; return (name == null ? other.name == null : name.equals(other.name)) && (type == null ? other.type == null : type.equals(other.type)) && (location == null ? other.location == null : location.equals(other.location)) && (metadata == null ? other.metadata == null : metadata.equals(other.metadata)) && (registration == null ? other.registration == null : registration.equals(other.registration)) && (status == null ? other.status == null : status.equals(other.status)); }
break; case "status": match = match(getStatus().name(), filter.getString("status")); break; case "type":
/** * @return the hash code of the current service record */ @Override public int hashCode() { int result = 17; result = 31 * result + (name == null ? 0 : name.hashCode()); result = 31 * result + (type == null ? 0 : type.hashCode()); result = 31 * result + (location == null ? 0 : location.hashCode()); result = 31 * result + (metadata == null ? 0 : metadata.hashCode()); result = 31 * result + (registration == null ? 0 : registration.hashCode()); result = 31 * result + (status == null ? 0 : status.hashCode()); return result; } }
/** * Get the GraphQL service proxy that is associated with the provided service record. * * @param discovery the service discovery instance * @param record the service record of a published GraphQL service * @param resultHandler the result handler */ static void getSchemaProxy(ServiceDiscovery discovery, Record record, Handler<AsyncResult<Queryable>> resultHandler) { Objects.requireNonNull(discovery, "Service discovery cannot be null"); Objects.requireNonNull(record, "Record cannot be null"); Objects.requireNonNull(resultHandler, "Schema proxy result handler cannot be null"); if (!SERVICE_TYPE.equals(record.getType())) { resultHandler.handle(Future.failedFuture("Record '" + record.getName() + "' is of wrong type '" + record.getType() + "'. Expected: " + SERVICE_TYPE)); } else if (!Status.UP.equals(record.getStatus())) { resultHandler.handle(Future.failedFuture("Record status indicates service '" + record.getName() + "' is: " + record.getStatus() + ". Expected: " + Status.UP)); } else if (record.getRegistration() == null) { resultHandler.handle(Future.failedFuture("Record '" + record.getName() + "' has no service discovery registration")); } else { ServiceReference reference = discovery.getReference(record); Queryable queryable = reference.cached() == null ? reference.get() : reference.cached(); reference.release(); resultHandler.handle(Future.succeededFuture(queryable)); } }
break; case "status": match = match(getStatus().name(), filter.getString("status")); break; case "type":
private void registerSchemaEventConsumers( ServiceDiscoveryOptions options, SchemaPublishedHandler<SchemaRegistration> publishedHandler, SchemaUnpublishedHandler<SchemaRegistration> unpublishedHandler) { SchemaAnnounceHandler announceHandler = record -> findRegistration(options.getName(), record.getName()).ifPresent(reg -> { if (Status.UP.equals(record.getStatus())) { publishedHandler.schemaPublished(reg); } else { unpublishedHandler.schemaUnpublished(reg); } }); consumerManager.registerConsumer(options.getAnnounceAddress(), announceHandler); }