Skip to content

Commit 4c27e84

Browse files
committed
WIP test for createSession
1 parent 6c45f77 commit 4c27e84

File tree

3 files changed

+277
-140
lines changed

3 files changed

+277
-140
lines changed

internal/coordination/client.go

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,15 +323,24 @@ func describeNode(
323323
}, nil
324324
}
325325

326-
func newCreateSessionConfig(opts ...options.SessionOption) *options.CreateSessionOptions {
326+
func applyToSession(t *trace.Coordination, opts ...options.SessionOption) sessionOption {
327327
c := defaultCreateSessionConfig()
328+
328329
for _, o := range opts {
329330
if o != nil {
330331
o(c)
331332
}
332333
}
333334

334-
return c
335+
return func(s *session) {
336+
s.trace = t
337+
s.description = c.Description
338+
s.sessionTimeout = c.SessionTimeout
339+
s.sessionStartTimeout = c.SessionStartTimeout
340+
s.sessionStopTimeout = c.SessionStopTimeout
341+
s.sessionKeepAliveTimeout = c.SessionKeepAliveTimeout
342+
s.sessionReconnectDelay = c.SessionReconnectDelay
343+
}
335344
}
336345

337346
func (c *Client) sessionCreated(s *session) {
@@ -385,7 +394,22 @@ func (c *Client) Session(
385394
onDone(finalErr)
386395
}()
387396

388-
return createSession(ctx, c, path, newCreateSessionConfig(opts...))
397+
s, err := createSession(ctx, c.client, path,
398+
applyToSession(c.config.Trace(), opts...),
399+
func(s *session) {
400+
s.onCreate = append(s.onCreate, func(s *session) {
401+
c.sessionCreated(s)
402+
})
403+
s.onClose = append(s.onClose, func(s *session) {
404+
c.sessionClosed(s)
405+
})
406+
},
407+
)
408+
if err != nil {
409+
return nil, xerrors.WithStackTrace(err)
410+
}
411+
412+
return s, nil
389413
}
390414

391415
func (c *Client) Close(ctx context.Context) (finalErr error) {

0 commit comments

Comments
 (0)