(ctx context.Context, sessionID uuid.UUID, originProxy io.ReadWriteCloser)
| 108 | } |
| 109 | |
| 110 | func (m *manager) RegisterSession(ctx context.Context, sessionID uuid.UUID, originProxy io.ReadWriteCloser) (*Session, error) { |
| 111 | ctx, cancel := context.WithTimeout(ctx, m.timeout) |
| 112 | defer cancel() |
| 113 | event := newRegisterSessionEvent(sessionID, originProxy) |
| 114 | select { |
| 115 | case <-ctx.Done(): |
| 116 | m.log.Error().Msg("Datagram session registration timeout") |
| 117 | return nil, ctx.Err() |
| 118 | case m.registrationChan <- event: |
| 119 | session := <-event.resultChan |
| 120 | return session, nil |
| 121 | // Once closedChan is closed, manager won't accept more registration because nothing is |
| 122 | // reading from registrationChan and it's an unbuffered channel |
| 123 | case <-m.closedChan: |
| 124 | return nil, errSessionManagerClosed |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | func (m *manager) registerSession(ctx context.Context, registration *registerSessionEvent) { |
| 129 | session := m.newSession(registration.sessionID, registration.originProxy) |
nothing calls this directly
no test coverage detected