| 1 | package edge |
| 2 | |
| 3 | // GenInfo is what the edge needs to know about an instance's CURRENT |
| 4 | // generation (zero-downtime spec §7.1, §7.2): the socket that takes new |
| 5 | // connections, the process-wide generation number the cache tags entries |
| 6 | // with, and the build X-Carlos-Version reports. |
| 7 | type GenInfo struct { |
| 8 | Socket string |
| 9 | N uint64 |
| 10 | Build string |
| 11 | } |
| 12 | |
| 13 | // GenSource is the activator's generation view, as the edge sees it. It is |
| 14 | // declared here for the reason Activator is: internal/activator imports |
| 15 | // this package, never the reverse. *activator.Service implements it. |
| 16 | // |
| 17 | // The edge uses it only when GenerationsOn reports true. With it false |
| 18 | // (CARLOS_SWAP unset, the default) every path below is skipped and the edge |
| 19 | // proxies, caches and stamps versions exactly as before. |
| 20 | type GenSource interface { |
| 21 | // GenerationsOn is the activator's dormant switch, read once when the |
| 22 | // activator was built. |
| 23 | GenerationsOn() bool |
| 24 | // AppSocket names the current generation's socket for traffic. False |
| 25 | // when the instance has no current generation (asleep, or waking). |
| 26 | AppSocket(host string) (socket string, ok bool) |
| 27 | // ServingGen is AppSocket with the generation's number and build. |
| 28 | ServingGen(host string) (GenInfo, bool) |
| 29 | // CacheGen is the newest generation that has been current for host in |
| 30 | // this process, kept after the instance sleeps so a sleeping instance's |
| 31 | // cached pages still answer. False when no generation of host has ever |
| 32 | // been current here. It must not take any lock the activator holds |
| 33 | // while calling into the cache. |
| 34 | CacheGen(host string) (uint64, bool) |
| 35 | // OnGenRetired registers fn to be called, synchronously and outside |
| 36 | // every activator lock, each time a generation stops being current. |
| 37 | // fn must not block. |
| 38 | OnGenRetired(fn func(host, socket string)) |
| 39 | } |
| 40 | |