MCPcopy Index your code
hub / github.com/cloudflare/cloudflared / RegisterSession

Method RegisterSession

datagramsession/manager.go:110–126  ·  view source on GitHub ↗
(ctx context.Context, sessionID uuid.UUID, originProxy io.ReadWriteCloser)

Source from the content-addressed store, hash-verified

108}
109
110func (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
128func (m *manager) registerSession(ctx context.Context, registration *registerSessionEvent) {
129 session := m.newSession(registration.sessionID, registration.originProxy)

Callers

nothing calls this directly

Calls 3

newRegisterSessionEventFunction · 0.85
ErrorMethod · 0.45
ErrMethod · 0.45

Tested by

no test coverage detected