Download this file
| 1 | package hostwrite |
| 2 | |
| 3 | import "context" |
| 4 | |
| 5 | // Selection carries the original work and rendered inputs across a callback. |
| 6 | // The receiver uses With at its final local effect, never a new hostname lookup. |
| 7 | // Network waits belong outside With; remote effects need a provider that binds |
| 8 | // the request to this selection and refuses a successor at publication. |
| 9 | type Selection struct { |
| 10 | Host string |
| 11 | Work Work |
| 12 | Identity Identity |
| 13 | } |
| 14 | |
| 15 | func (s Selection) With(ctx context.Context, effect func() error) error { |
| 16 | if ctx == nil || s.Host == "" || s.Work == nil || effect == nil { |
| 17 | return ErrUnavailable |
| 18 | } |
| 19 | return s.Work.With(ctx, s.Identity, effect) |
| 20 | } |
| 21 | |
| 22 | type Callback func(context.Context, Selection) error |
| 23 | |