| 1 | package boot |
| 2 | |
| 3 | import ( |
| 4 | "errors" |
| 5 | "reasonix/internal/control" |
| 6 | ) |
| 7 | |
| 8 | func (opts *Options) inheritSessionBinding(old *control.Controller) { |
| 9 | opts.NativeLegacySession = old.NativeLegacySession() || (!old.UsesExclusiveSession() && old.SessionPath() != "") |
| 10 | opts.SessionCreateService = old.SessionCreationService() |
| 11 | if opts.NativeLegacySession && old.SessionService() != nil { |
| 12 | opts.SessionService = old.SessionService() |
| 13 | } |
| 14 | if service, runtime, ok := old.SessionBinding(); ok { |
| 15 | opts.SessionService = service |
| 16 | opts.SessionRuntime = runtime |
| 17 | opts.SessionHostID = runtime.Ref().HostID |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | func (opts Options) validateSessionBinding() error { |
| 22 | if opts.NativeLegacySession && opts.SessionRuntime != nil { |
| 23 | return errors.New("native legacy session cannot bind a canonical runtime") |
| 24 | } |
| 25 | if opts.SessionRuntime != nil && opts.SessionService == nil { |
| 26 | return errors.New("v3 session runtime requires a session service") |
| 27 | } |
| 28 | return nil |
| 29 | } |
| 30 |