Package com.tnsai.hooks.events
Record Class SessionEnd
java.lang.Object
java.lang.Record
com.tnsai.hooks.events.SessionEnd
- Record Components:
eventId- ULID-shaped correlation id (matches the corresponding SessionStart)timestamp- when the session closedcontext- surrounding hook contextsessionId- framework session idreason- why the session closedlifetime- total session duration (Instant.now() - sessionStart)messageCount- total messages exchangedcause- throwable whenreasonisSessionCloseReason.ERROR; empty otherwise
- All Implemented Interfaces:
HookEvent,SessionHookEvent
public record SessionEnd(String eventId, Instant timestamp, HookContext context, String sessionId, SessionCloseReason reason, Duration lifetime, long messageCount, Optional<Throwable> cause)
extends Record
implements SessionHookEvent
Fires when a client session closes for any reason (issue #63).
Counterpart to
SessionStart — flush telemetry, persist
state, write a final audit entry.
Block on SessionEnd is meaningless (the session is
already gone); hooks here are observation-only by convention.
The dispatcher still honors Block but the server has
nothing to refuse.
cause is populated only when reason is
SessionCloseReason.ERROR; other reasons carry an empty
Optional. Validated at construction.
- Since:
- 0.5.0 (issue #63)
-
Constructor Summary
ConstructorsConstructorDescriptionSessionEnd(String eventId, Instant timestamp, HookContext context, String sessionId, SessionCloseReason reason, Duration lifetime, long messageCount, Optional<Throwable> cause) Creates an instance of aSessionEndrecord class. -
Method Summary
Modifier and TypeMethodDescriptioncause()Returns the value of thecauserecord component.context()Returns the value of thecontextrecord component.final booleanIndicates whether some other object is "equal to" this one.eventId()Returns the value of theeventIdrecord component.Short stable string identifier of the event kind, e.g.final inthashCode()Returns a hash code value for this object.lifetime()Returns the value of thelifetimerecord component.longReturns the value of themessageCountrecord component.reason()Returns the value of thereasonrecord component.Returns the value of thesessionIdrecord component.Returns the value of thetimestamprecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
SessionEnd
public SessionEnd(String eventId, Instant timestamp, HookContext context, String sessionId, SessionCloseReason reason, Duration lifetime, long messageCount, Optional<Throwable> cause) Creates an instance of aSessionEndrecord class.- Parameters:
eventId- the value for theeventIdrecord componenttimestamp- the value for thetimestamprecord componentcontext- the value for thecontextrecord componentsessionId- the value for thesessionIdrecord componentreason- the value for thereasonrecord componentlifetime- the value for thelifetimerecord componentmessageCount- the value for themessageCountrecord componentcause- the value for thecauserecord component
-
-
Method Details
-
eventType
Description copied from interface:HookEventShort stable string identifier of the event kind, e.g."PreToolUse". Default implementation derives it from the concrete record's simple class name; concrete records may override if a different naming is desirable. -
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 '=='. -
eventId
Returns the value of theeventIdrecord component. -
timestamp
Returns the value of thetimestamprecord component. -
context
Returns the value of thecontextrecord component. -
sessionId
Returns the value of thesessionIdrecord component.- Returns:
- the value of the
sessionIdrecord component
-
reason
Returns the value of thereasonrecord component.- Returns:
- the value of the
reasonrecord component
-
lifetime
Returns the value of thelifetimerecord component.- Returns:
- the value of the
lifetimerecord component
-
messageCount
public long messageCount()Returns the value of themessageCountrecord component.- Returns:
- the value of the
messageCountrecord component
-
cause
Returns the value of thecauserecord component.- Returns:
- the value of the
causerecord component
-