Record Class HubSpokeResult
java.lang.Object
java.lang.Record
com.tnsai.coordination.groups.hubspoke.HubSpokeResult
- Record Components:
taskId- task identifiersuccess- whether the operation succeededoutput- output from the spokespokeId- which spoke handled the taskloadDistribution- load at time of routingstartedAt- start timecompletedAt- completion timeerror- error message if failed
public record HubSpokeResult(String taskId, boolean success, String output, String spokeId, Map<String,Integer> loadDistribution, Instant startedAt, Instant completedAt, String error)
extends Record
Result of a hub-spoke operation.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecompletedAtrecord component.final booleanIndicates whether some other object is "equal to" this one.error()Returns the value of theerrorrecord component.static HubSpokeResultCreates a failed result.Gets execution duration.final inthashCode()Returns a hash code value for this object.Returns the value of theloadDistributionrecord component.output()Returns the value of theoutputrecord component.spokeId()Returns the value of thespokeIdrecord component.Returns the value of thestartedAtrecord component.booleansuccess()Returns the value of thesuccessrecord component.static HubSpokeResultsuccess(String taskId, String output, String spokeId, Map<String, Integer> loadDistribution, Instant startedAt) Creates a successful result.taskId()Returns the value of thetaskIdrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
HubSpokeResult
public HubSpokeResult(String taskId, boolean success, String output, String spokeId, Map<String, Integer> loadDistribution, Instant startedAt, Instant completedAt, String error) Creates an instance of aHubSpokeResultrecord class.- Parameters:
taskId- the value for thetaskIdrecord componentsuccess- the value for thesuccessrecord componentoutput- the value for theoutputrecord componentspokeId- the value for thespokeIdrecord componentloadDistribution- the value for theloadDistributionrecord componentstartedAt- the value for thestartedAtrecord componentcompletedAt- the value for thecompletedAtrecord componenterror- the value for theerrorrecord component
-
-
Method Details
-
success
public static HubSpokeResult success(String taskId, String output, String spokeId, Map<String, Integer> loadDistribution, Instant startedAt) Creates a successful result.- Parameters:
taskId- task IDoutput- spoke outputspokeId- spoke that handled itloadDistribution- load distributionstartedAt- start time- Returns:
- successful result
-
failure
Creates a failed result.- Parameters:
taskId- task IDerror- error messagestartedAt- start time- Returns:
- failed result
-
getDuration
Gets execution duration.- Returns:
- duration
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
taskId
Returns the value of thetaskIdrecord component.- Returns:
- the value of the
taskIdrecord component
-
success
public boolean success()Returns the value of thesuccessrecord component.- Returns:
- the value of the
successrecord component
-
output
Returns the value of theoutputrecord component.- Returns:
- the value of the
outputrecord component
-
spokeId
Returns the value of thespokeIdrecord component.- Returns:
- the value of the
spokeIdrecord component
-
loadDistribution
Returns the value of theloadDistributionrecord component.- Returns:
- the value of the
loadDistributionrecord component
-
startedAt
Returns the value of thestartedAtrecord component.- Returns:
- the value of the
startedAtrecord component
-
completedAt
Returns the value of thecompletedAtrecord component.- Returns:
- the value of the
completedAtrecord component
-
error
Returns the value of theerrorrecord component.- Returns:
- the value of the
errorrecord component
-