Skip to content

Commit

Permalink
Merge pull request #675 from ackleymi/interface-getters
Browse files Browse the repository at this point in the history
Adds convenience getters for session log and store
  • Loading branch information
ackleymi authored Sep 25, 2024
2 parents c2cd79a + 90867a2 commit c7392e8
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,24 @@ func GetExpectedTargetNum(sessionID SessionID) (int, error) {
return session.store.NextTargetMsgSeqNum(), nil
}

// GetMessageStore returns the MessageStore interface for session matching the session id.
func GetMessageStore(sessionID SessionID) (MessageStore, error) {
session, ok := lookupSession(sessionID)
if !ok {
return nil, errUnknownSession
}
return session.store, nil
}

// GetLog returns the Log interface for session matching the session id.
func GetLog(sessionID SessionID) (Log, error) {
session, ok := lookupSession(sessionID)
if !ok {
return nil, errUnknownSession
}
return session.log, nil
}

func registerSession(s *session) error {
sessionsLock.Lock()
defer sessionsLock.Unlock()
Expand Down

0 comments on commit c7392e8

Please sign in to comment.