|
| 1 | +title = "SIP xxx - Spin Geo interface" |
| 2 | +template = "main" |
| 3 | +date = "2025-08-19T12:00:00Z" |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +Summary: Introduce new `spin:geo` interface |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | +Created: Aug 19, 2025 |
| 12 | + |
| 13 | +## Background |
| 14 | + |
| 15 | +TODO |
| 16 | + |
| 17 | +## Proposal |
| 18 | + |
| 19 | +### WIT Interfaces |
| 20 | + |
| 21 | +```wit |
| 22 | +package spin:geo; |
| 23 | +
|
| 24 | +interface types { |
| 25 | + struct position { |
| 26 | + // WGS 84 (i.e. GPS) coordinates |
| 27 | + latitude: f32; |
| 28 | + longitude: f32; |
| 29 | + // Estimated radius around coordinates of actual location, in meters |
| 30 | + accuracy: option<f32>; |
| 31 | + } |
| 32 | +
|
| 33 | + // Represents a geographic location. |
| 34 | + resource location { |
| 35 | + // A geolocation position |
| 36 | + position: func() -> option<position>; |
| 37 | +
|
| 38 | + // ISO 3166-1 alpha-2 code (uppercase) |
| 39 | + country-code: func() -> option<string>; |
| 40 | +
|
| 41 | + // The three letter part of a UN/LOCODE code (uppercase) |
| 42 | + // Note: This will often match a nearby IATA airport code. |
| 43 | + local-code: func() -> option<string>; |
| 44 | + } |
| 45 | +} |
| 46 | +
|
| 47 | +interface host { |
| 48 | + struct provider-region { |
| 49 | + // The name of the provider; see: |
| 50 | + // https://opentelemetry.io/docs/specs/semconv/registry/attributes/cloud/#cloud-provider |
| 51 | + provider: string, |
| 52 | +
|
| 53 | + // A provider-specific region identifier; see: |
| 54 | + // https://opentelemetry.io/docs/specs/semconv/registry/attributes/cloud/#cloud-region |
| 55 | + region: string |
| 56 | + } |
| 57 | +
|
| 58 | + // Returns the location of the host running this process. |
| 59 | + location: func() -> option<location>; |
| 60 | +
|
| 61 | + provider-region: func() -> option<provider-region>; |
| 62 | +} |
| 63 | +
|
| 64 | +interface internet { |
| 65 | + variant error { |
| 66 | + // No location information found for the given address |
| 67 | + not-found, |
| 68 | + // The address was malformed or not a public internet address |
| 69 | + invalid-ip-address, |
| 70 | + // Some implementation-specific error occurred |
| 71 | + other(string), |
| 72 | + } |
| 73 | +
|
| 74 | + // Returns a location for the given IP address. |
| 75 | + lookup: func(ip-address: string) -> result<location, error>; |
| 76 | +} |
| 77 | +``` |
0 commit comments