Skip to content

Commit c7392e8

Browse files
authored
Merge pull request #675 from ackleymi/interface-getters
Adds convenience getters for session log and store
2 parents c2cd79a + 90867a2 commit c7392e8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

registry.go

+18
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,24 @@ func GetExpectedTargetNum(sessionID SessionID) (int, error) {
129129
return session.store.NextTargetMsgSeqNum(), nil
130130
}
131131

132+
// GetMessageStore returns the MessageStore interface for session matching the session id.
133+
func GetMessageStore(sessionID SessionID) (MessageStore, error) {
134+
session, ok := lookupSession(sessionID)
135+
if !ok {
136+
return nil, errUnknownSession
137+
}
138+
return session.store, nil
139+
}
140+
141+
// GetLog returns the Log interface for session matching the session id.
142+
func GetLog(sessionID SessionID) (Log, error) {
143+
session, ok := lookupSession(sessionID)
144+
if !ok {
145+
return nil, errUnknownSession
146+
}
147+
return session.log, nil
148+
}
149+
132150
func registerSession(s *session) error {
133151
sessionsLock.Lock()
134152
defer sessionsLock.Unlock()

0 commit comments

Comments
 (0)