Documentation
¶
Overview ¶
Package sample provides a Connect service for ingress experiments.
Index ¶
- type ForecastClient
- type ForecastProvider
- type Server
- type Service
- func (s *Service) GetUser(ctx context.Context, request *connect.Request[samplepb.GetUserRequest]) (*connect.Response[samplepb.GetUserResponse], error)
- func (s *Service) ListUsers(ctx context.Context, request *connect.Request[samplepb.ListUsersRequest]) (*connect.Response[samplepb.ListUsersResponse], error)
- type Weather
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ForecastClient ¶ added in v0.16.0
type ForecastClient struct {
// contains filtered or unexported fields
}
ForecastClient fetches forecasts from a ForecastProvider, usually through egress. It sends the provider's host name so egress can select the destination.
func NewForecastClient ¶ added in v0.16.0
func NewForecastClient(target *url.URL, host string, transport http.RoundTripper, log *slog.Logger) *ForecastClient
NewForecastClient sends requests for host to target through transport.
func (*ForecastClient) Fetch ¶ added in v0.16.0
func (c *ForecastClient) Fetch(ctx context.Context, location string) (forecast *samplepb.Forecast, status int)
Fetch returns the forecast for a location, or the status to report instead. A provider failure other than an unknown location is reported as a bad gateway.
type ForecastProvider ¶ added in v0.16.0
type ForecastProvider struct {
// contains filtered or unexported fields
}
ForecastProvider serves the raw HTTP JSON forecast API that the weather sample calls in dependency mode. ForecastProviderService in forecasts.proto types it.
func NewForecastProvider ¶ added in v0.16.0
func NewForecastProvider(data []byte) (*ForecastProvider, error)
NewForecastProvider loads forecasts from the same data format as NewWeather, ignoring alerts.
func (*ForecastProvider) FetchForecast ¶ added in v0.16.0
func (p *ForecastProvider) FetchForecast(writer http.ResponseWriter, request *http.Request)
FetchForecast serves GET /v1/forecasts/{location}.
type Server ¶ added in v0.3.0
type Server struct {
// contains filtered or unexported fields
}
Server serves sample Connect requests and HTTP health checks on one listener.
func NewServer ¶ added in v0.3.0
NewServer constructs a sample server around a configured Connect handler.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service serves a read-only snapshot loaded from ProtoJSON.
type Weather ¶ added in v0.12.0
type Weather struct {
// contains filtered or unexported fields
}
Weather serves raw HTTP JSON endpoints modelled on a legacy weather service. WeatherService in weather.proto types its responses.
func NewWeather ¶ added in v0.12.0
func NewWeather(data []byte, revision string, forecasts *ForecastClient) (*Weather, error)
NewWeather loads weather from a JSON object mapping locations to ProtoJSON GetForecastV2Response values. A non-nil forecasts client enables dependency mode.
func (*Weather) GetForecast ¶ added in v0.12.0
func (w *Weather) GetForecast(writer http.ResponseWriter, request *http.Request)
GetForecast serves GET /api/v1/forecast for a location.
func (*Weather) GetForecastV2 ¶ added in v0.12.0
func (w *Weather) GetForecastV2(writer http.ResponseWriter, request *http.Request)
GetForecastV2 serves GET /v2/forecast for a location, including its alerts.