flightbookingapi

package
v1.45.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const Description = `` /* 193-byte string literal not displayed */

Description is the human-readable summary of the microservice, surfaced in OpenAPI and discovery.

View Source
const Hostname = "flightbooking.example"

Hostname is the default hostname of the microservice.

View Source
const Name = "FlightBooking"

Name is the decorative PascalCase name of the microservice.

View Source
const Version = 1

Version is a generation counter bumped on each regeneration, not a semantic version.

Variables

View Source
var AwaitDecision = define.Task{
	Host: Hostname, Method: "POST", Route: ":428/await-decision",
	In: AwaitDecisionIn{}, Out: AwaitDecisionOut{},
}

AwaitDecision parks the flow on a human accept/keep-searching decision for the proposed flight and advances to the next candidate when the traveler keeps searching.

View Source
var BookFlight = define.Workflow{
	Host: Hostname, Method: "GET", Route: ":428/book-flight",
	In: BookFlightIn{}, Out: BookFlightOut{},
}

BookFlight is the top-level agentic workflow. It searches the route, then loops proposing one candidate flight at a time and parking on a human accept/keep-searching decision via Interrupt. On acceptance it invokes the ChooseSeatAgent child workflow as an isolated subgraph to pick a seat, then confirms the booking.

View Source
var ChooseSeat = define.Task{
	Host: Hostname, Method: "POST", Route: ":428/choose-seat",
	In: ChooseSeatIn{}, Out: ChooseSeatOut{},
}

ChooseSeat delegates seat selection for the accepted flight to the ChooseSeatAgent child workflow.

View Source
var ChooseSeatAgent = define.Workflow{
	Host: Hostname, Method: "GET", Route: ":428/choose-seat-agent",
	In: ChooseSeatAgentIn{}, Out: ChooseSeatAgentOut{},
}

ChooseSeatAgent is a child workflow that selects a single seat from a flight's available seats to match a natural-language preference. It is invoked as an isolated subgraph by the BookFlight workflow's ChooseSeat task.

View Source
var ConfirmBooking = define.Task{
	Host: Hostname, Method: "POST", Route: ":428/confirm-booking",
	In: ConfirmBookingIn{}, Out: ConfirmBookingOut{},
}

ConfirmBooking finalizes the booking of the accepted flight and chosen seat into a confirmation.

View Source
var Demo = define.Web{
	Host: Hostname, Method: "ANY", Route: "/demo",
}

Demo serves the human-in-the-loop demo page that drives the BookFlight workflow, presenting each proposed flight and resuming the parked flow with the traveler's accept or keep-searching decision.

View Source
var NoFlights = define.Task{
	Host: Hostname, Method: "POST", Route: ":428/no-flights",
	In: NoFlightsIn{}, Out: NoFlightsOut{},
}

NoFlights ends the workflow with a not-booked message when no flight is available or every candidate is declined.

View Source
var PickSeat = define.Task{
	Host: Hostname, Method: "POST", Route: ":428/pick-seat",
	In: PickSeatIn{}, Out: PickSeatOut{},
}

PickSeat asks the LLM to choose one seat from the available list that best matches the traveler's preference.

View Source
var ProposeFlight = define.Task{
	Host: Hostname, Method: "POST", Route: ":428/propose-flight",
	In: ProposeFlightIn{}, Out: ProposeFlightOut{},
}

ProposeFlight selects the candidate at the current index, or marks the search exhausted when the list runs out.

View Source
var SearchFlights = define.Task{
	Host: Hostname, Method: "POST", Route: ":428/search-flights",
	In: SearchFlightsIn{}, Out: SearchFlightsOut{},
}

SearchFlights looks up the flights serving a route and seeds the candidate list for the workflow to propose.

Functions

This section is empty.

Types

type AwaitDecisionIn

type AwaitDecisionIn struct {
	CurrentFlight Flight `json:"currentFlight,omitzero"`
	FlightIndex   int    `json:"flightIndex,omitzero"`
}

AwaitDecisionIn are the input arguments of AwaitDecision.

type AwaitDecisionOut

type AwaitDecisionOut struct {
	Accepted       bool `json:"accepted,omitzero"`
	FlightIndexOut int  `json:"flightIndex,omitzero"`
}

AwaitDecisionOut are the output arguments of AwaitDecision.

type BookFlightIn

type BookFlightIn struct {
	Origin         string `json:"origin,omitzero" jsonschema_description:"Origin is the departure city, e.g. San Francisco"`
	Destination    string `json:"destination,omitzero" jsonschema_description:"Destination is the arrival city, e.g. London"`
	SeatPreference string `` /* 140-byte string literal not displayed */
}

BookFlightIn are the input arguments of BookFlight.

type BookFlightOut

type BookFlightOut struct {
	Confirmation string `` /* 134-byte string literal not displayed */
	Airline      string `json:"airline,omitzero" jsonschema_description:"Airline is the booked flight's airline"`
	FlightNo     string `json:"flightNo,omitzero" jsonschema_description:"FlightNo is the booked flight number"`
	Seat         string `json:"seat,omitzero" jsonschema_description:"Seat is the assigned seat label"`
}

BookFlightOut are the output arguments of BookFlight.

type ChooseSeatAgentIn

type ChooseSeatAgentIn struct {
	SeatPreference string   `` /* 138-byte string literal not displayed */
	AvailableSeats []string `` /* 138-byte string literal not displayed */
}

ChooseSeatAgentIn are the input arguments of ChooseSeatAgent.

type ChooseSeatAgentOut

type ChooseSeatAgentOut struct {
	Seat string `json:"seat,omitzero" jsonschema_description:"Seat is the chosen seat label"`
}

ChooseSeatAgentOut are the output arguments of ChooseSeatAgent.

type ChooseSeatIn

type ChooseSeatIn struct {
	SeatPreference string `json:"seatPreference,omitzero"`
	CurrentFlight  Flight `json:"currentFlight,omitzero"`
}

ChooseSeatIn are the input arguments of ChooseSeat.

type ChooseSeatOut

type ChooseSeatOut struct {
	Seat string `json:"seat,omitzero"`
}

ChooseSeatOut are the output arguments of ChooseSeat.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a lightweight proxy for making unicast calls to the microservice.

func NewClient

func NewClient(caller service.Publisher) Client

NewClient creates a new unicast client proxy to the microservice.

func (Client) Demo

func (_c Client) Demo(ctx context.Context, method string, relativeURL string, body any) (res *http.Response, err error)

Demo serves the human-in-the-loop demo page that drives the BookFlight workflow, presenting each proposed flight and resuming the parked flow with the traveler's accept or keep-searching decision.

func (Client) ForHost

func (_c Client) ForHost(host string) Client

ForHost returns a copy of the client with a different hostname to be applied to requests.

func (Client) WithOptions

func (_c Client) WithOptions(opts ...pub.Option) Client

WithOptions returns a copy of the client with options to be applied to requests.

type ConfirmBookingIn

type ConfirmBookingIn struct {
	CurrentFlight Flight `json:"currentFlight,omitzero"`
	Seat          string `json:"seat,omitzero"`
}

ConfirmBookingIn are the input arguments of ConfirmBooking.

type ConfirmBookingOut

type ConfirmBookingOut struct {
	Confirmation string `json:"confirmation,omitzero"`
	Airline      string `json:"airline,omitzero"`
	FlightNo     string `json:"flightNo,omitzero"`
}

ConfirmBookingOut are the output arguments of ConfirmBooking.

type Executor

type Executor struct {
	// contains filtered or unexported fields
}

Executor runs tasks and workflows synchronously, blocking until termination. It is primarily intended for integration tests.

func NewExecutor

func NewExecutor(caller service.Publisher) Executor

NewExecutor creates a new executor proxy to the microservice.

func (Executor) AwaitDecision

func (_c Executor) AwaitDecision(ctx context.Context, currentFlight Flight, flightIndex int) (accepted bool, flightIndexOut int, err error)

AwaitDecision parks the flow on a human accept/keep-searching decision for the proposed flight and advances to the next candidate when the traveler keeps searching.

func (Executor) BookFlight

func (_c Executor) BookFlight(ctx context.Context, origin string, destination string, seatPreference string) (confirmation string, airline string, flightNo string, seat string, status string, err error)

BookFlight is the top-level agentic workflow. It searches the route, then loops proposing one candidate flight at a time and parking on a human accept/keep-searching decision via Interrupt. On acceptance it invokes the ChooseSeatAgent child workflow as an isolated subgraph to pick a seat, then confirms the booking.

func (Executor) ChooseSeat

func (_c Executor) ChooseSeat(ctx context.Context, seatPreference string, currentFlight Flight) (seat string, err error)

ChooseSeat delegates seat selection for the accepted flight to the ChooseSeatAgent child workflow.

func (Executor) ChooseSeatAgent

func (_c Executor) ChooseSeatAgent(ctx context.Context, seatPreference string, availableSeats []string) (seat string, status string, err error)

ChooseSeatAgent is a child workflow that selects a single seat from a flight's available seats to match a natural-language preference. It is invoked as an isolated subgraph by the BookFlight workflow's ChooseSeat task.

func (Executor) ConfirmBooking

func (_c Executor) ConfirmBooking(ctx context.Context, currentFlight Flight, seat string) (confirmation string, airline string, flightNo string, err error)

ConfirmBooking finalizes the booking of the accepted flight and chosen seat into a confirmation.

func (Executor) ForHost

func (_c Executor) ForHost(host string) Executor

ForHost returns a copy of the executor with a different hostname to be applied to requests.

func (Executor) NoFlights

func (_c Executor) NoFlights(ctx context.Context) (confirmation string, err error)

NoFlights ends the workflow with a not-booked message when no flight is available or every candidate is declined.

func (Executor) PickSeat

func (_c Executor) PickSeat(ctx context.Context, seatPreference string, availableSeats []string) (seat string, err error)

PickSeat asks the LLM to choose one seat from the available list that best matches the traveler's preference.

func (Executor) ProposeFlight

func (_c Executor) ProposeFlight(ctx context.Context, candidates []Flight, flightIndex int) (currentFlight Flight, exhausted bool, err error)

ProposeFlight selects the candidate at the current index, or marks the search exhausted when the list runs out.

func (Executor) SearchFlights

func (_c Executor) SearchFlights(ctx context.Context, origin string, destination string) (candidates []Flight, flightIndex int, err error)

SearchFlights looks up the flights serving a route and seeds the candidate list for the workflow to propose.

func (Executor) WithFlowOptions

func (_c Executor) WithFlowOptions(flowOptions *workflow.FlowOptions) Executor

WithFlowOptions returns a copy of the executor that creates workflows with the given flow options (priority, fairness key and weight). It has no effect on task execution.

func (Executor) WithInputFlow

func (_c Executor) WithInputFlow(flow *workflow.Flow) Executor

WithInputFlow returns a copy of the executor with an input flow to use for task execution. The input flow's state is available to the task in addition to the typed input arguments.

func (Executor) WithOptions

func (_c Executor) WithOptions(opts ...pub.Option) Executor

WithOptions returns a copy of the executor with options to be applied to requests.

func (Executor) WithOutputFlow

func (_c Executor) WithOutputFlow(flow *workflow.Flow) Executor

WithOutputFlow returns a copy of the executor with an output flow to populate after task execution. The output flow captures the full flow state including control signals (Goto, Retry, Interrupt, Sleep).

func (Executor) WithWorkflowRunner

func (_c Executor) WithWorkflowRunner(runner WorkflowRunner) Executor

WithWorkflowRunner returns a copy of the executor with a workflow runner for executing workflows. foremanapi.NewClient(svc) satisfies the WorkflowRunner interface.

type Flight

type Flight struct {
	Airline     string   `json:"airline,omitzero" jsonschema_description:"Airline is the operating carrier"`
	FlightNo    string   `json:"flightNo,omitzero" jsonschema_description:"FlightNo is the flight number"`
	Origin      string   `json:"origin,omitzero" jsonschema_description:"Origin is the departure city"`
	Destination string   `json:"destination,omitzero" jsonschema_description:"Destination is the arrival city"`
	Depart      string   `json:"depart,omitzero" jsonschema_description:"Depart is the local departure time, e.g. 08:15"`
	Arrive      string   `json:"arrive,omitzero" jsonschema_description:"Arrive is the local arrival time, e.g. 16:40"`
	Stops       int      `json:"stops,omitzero" jsonschema_description:"Stops is the number of connections, 0 for non-stop"`
	PriceUSD    int      `json:"priceUSD,omitzero" jsonschema_description:"PriceUSD is the fare in US dollars"`
	Seats       []string `json:"seats,omitzero" jsonschema_description:"Seats are the available seat labels on this flight"`
}

Flight is a single candidate itinerary on a route.

type MulticastClient

type MulticastClient struct {
	// contains filtered or unexported fields
}

MulticastClient is a lightweight proxy for making multicast calls to the microservice.

func NewMulticastClient

func NewMulticastClient(caller service.Publisher) MulticastClient

NewMulticastClient creates a new multicast client proxy to the microservice.

func (MulticastClient) Demo

func (_c MulticastClient) Demo(ctx context.Context, method string, relativeURL string, body any) iter.Seq[*pub.Response]

Demo serves the human-in-the-loop demo page that drives the BookFlight workflow, presenting each proposed flight and resuming the parked flow with the traveler's accept or keep-searching decision.

func (MulticastClient) ForHost

func (_c MulticastClient) ForHost(host string) MulticastClient

ForHost returns a copy of the client with a different hostname to be applied to requests.

func (MulticastClient) WithOptions

func (_c MulticastClient) WithOptions(opts ...pub.Option) MulticastClient

WithOptions returns a copy of the client with options to be applied to requests.

type NoFlightsIn

type NoFlightsIn struct {
}

NoFlightsIn are the input arguments of NoFlights.

type NoFlightsOut

type NoFlightsOut struct {
	Confirmation string `json:"confirmation,omitzero"`
}

NoFlightsOut are the output arguments of NoFlights.

type PickSeatIn

type PickSeatIn struct {
	SeatPreference string   `json:"seatPreference,omitzero"`
	AvailableSeats []string `json:"availableSeats,omitzero"`
}

PickSeatIn are the input arguments of PickSeat.

type PickSeatOut

type PickSeatOut struct {
	Seat string `json:"seat,omitzero"`
}

PickSeatOut are the output arguments of PickSeat.

type ProposeFlightIn

type ProposeFlightIn struct {
	Candidates  []Flight `json:"candidates,omitzero"`
	FlightIndex int      `json:"flightIndex,omitzero"`
}

ProposeFlightIn are the input arguments of ProposeFlight.

type ProposeFlightOut

type ProposeFlightOut struct {
	CurrentFlight Flight `json:"currentFlight,omitzero"`
	Exhausted     bool   `json:"exhausted,omitzero"`
}

ProposeFlightOut are the output arguments of ProposeFlight.

type SearchFlightsIn

type SearchFlightsIn struct {
	Origin      string `json:"origin,omitzero"`
	Destination string `json:"destination,omitzero"`
}

SearchFlightsIn are the input arguments of SearchFlights.

type SearchFlightsOut

type SearchFlightsOut struct {
	Candidates  []Flight `json:"candidates,omitzero"`
	FlightIndex int      `json:"flightIndex,omitzero"`
}

SearchFlightsOut are the output arguments of SearchFlights.

type Subgraph

type Subgraph struct {
	// contains filtered or unexported fields
}

Subgraph runs this microservice's workflows from inside a task body. Create it with NewSubgraph(flow), then call the method named after the workflow you want to invoke.

func NewSubgraph

func NewSubgraph(flow *workflow.Flow) Subgraph

NewSubgraph creates a subgraph client bound to the calling task's flow carrier.

func (Subgraph) BookFlight

func (_sg Subgraph) BookFlight(ctx context.Context, origin string, destination string, seatPreference string) (confirmation string, airline string, flightNo string, seat string, yield bool, err error)

BookFlight is the top-level agentic workflow. It searches the route, then loops proposing one candidate flight at a time and parking on a human accept/keep-searching decision via Interrupt. On acceptance it invokes the ChooseSeatAgent child workflow as an isolated subgraph to pick a seat, then confirms the booking.

func (Subgraph) ChooseSeatAgent

func (_sg Subgraph) ChooseSeatAgent(ctx context.Context, seatPreference string, availableSeats []string) (seat string, yield bool, err error)

ChooseSeatAgent is a child workflow that selects a single seat from a flight's available seats to match a natural-language preference. It is invoked as an isolated subgraph by the BookFlight workflow's ChooseSeat task.

type WorkflowRunner

type WorkflowRunner interface {
	Run(ctx context.Context, workflowName string, initialState any, opts *workflow.FlowOptions) (outcome *workflow.FlowOutcome, err error)
}

WorkflowRunner executes a workflow by name with initial state, blocking until termination. foremanapi.Client satisfies this interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL