| 1 | package moves |
| 2 | |
| 3 | import "fmt" |
| 4 | |
| 5 | // The operator sentences two packages speak (preflight L12): the carlos move |
| 6 | // CLI (package main) and the app's member stream (internal/host). One |
| 7 | // template each, so the copy record names this file for them. A sentence |
| 8 | // only one of them speaks stays in that file. |
| 9 | |
| 10 | // MoveStartingLine is M-C1. |
| 11 | func MoveStartingLine(host, from, to string) string { |
| 12 | return fmt.Sprintf("Moving %s from %s to %s.", host, from, to) |
| 13 | } |
| 14 | |
| 15 | // CutStartingLine is M-C5; estimate is CutBudgetText's. |
| 16 | func CutStartingLine(to, host, estimate string) string { |
| 17 | return fmt.Sprintf("%s is ready. Starting the cut. %s will be offline for about %s.", to, host, estimate) |
| 18 | } |
| 19 | |
| 20 | // FlippedLine is M-C6. |
| 21 | func FlippedLine(from, to string) string { |
| 22 | return fmt.Sprintf("Stopped in %s. Starting in %s.", from, to) |
| 23 | } |
| 24 | |
| 25 | // MovedLine is M-C7. |
| 26 | func MovedLine(host, to string, offlineSeconds int) string { |
| 27 | return fmt.Sprintf("Moved. %s is served from %s. It was offline for %d seconds.", host, to, offlineSeconds) |
| 28 | } |
| 29 | |
| 30 | // MovingBackLine is M-C8; reason is a recorded rollback sentence. |
| 31 | func MovingBackLine(to, host, reason, from string) string { |
| 32 | return fmt.Sprintf("%s could not start %s: %s. Moving it back to %s.", to, host, reason, from) |
| 33 | } |
| 34 | |
| 35 | // MovedBackLine is M-C9. |
| 36 | func MovedBackLine(host, from string) string { |
| 37 | return fmt.Sprintf("%s is back in %s and serving. Nothing was lost.", host, from) |
| 38 | } |
| 39 | |
| 40 | // StuckMemberLine is what members read for a stuck move (MV-N380): M-C11 |
| 41 | // without the operator's command. |
| 42 | func StuckMemberLine(host, to, from string) string { |
| 43 | return fmt.Sprintf("%s could not start in %s or in %s. It is offline. An operator has been paged.", host, to, from) |
| 44 | } |
| 45 | |
| 46 | // CutBudgetText renders a cut budget for M-C5. |
| 47 | func CutBudgetText(seconds int) string { |
| 48 | if seconds < 90 { |
| 49 | return fmt.Sprintf("%d seconds", seconds) |
| 50 | } |
| 51 | return fmt.Sprintf("%d minutes", (seconds+59)/60) |
| 52 | } |
| 53 | |
| 54 | // HomeRegionText names the home region where only its code, "", is known |
| 55 | // (MV-N381): a box knows the deployment's home only as the record's empty |
| 56 | // region. |
| 57 | const HomeRegionText = "the home region" |
| 58 | |
| 59 | // RegionText is a region as a sentence names it: its code, or |
| 60 | // HomeRegionText for the home's "". |
| 61 | func RegionText(code string) string { |
| 62 | if code == "" { |
| 63 | return HomeRegionText |
| 64 | } |
| 65 | return code |
| 66 | } |
| 67 | |