Documentation ¶
Index ¶
- Variables
- func WithBookingApiClientFactory(f func(name string) (traits.BookingApiClient, error)) router.Option
- func WithBookingInfoClientFactory(f func(name string) (traits.BookingInfoClient, error)) router.Option
- func WithBookingOption(opts ...resource.Option) resource.Option
- func WithInitialBooking(bookings ...*traits.Booking) resource.Option
- type ApiRouter
- func (r *ApiRouter) Add(name string, client any) any
- func (r *ApiRouter) AddBookingApiClient(name string, client traits.BookingApiClient) traits.BookingApiClient
- func (r *ApiRouter) CheckInBooking(ctx context.Context, request *traits.CheckInBookingRequest) (*traits.CheckInBookingResponse, error)
- func (r *ApiRouter) CheckOutBooking(ctx context.Context, request *traits.CheckOutBookingRequest) (*traits.CheckOutBookingResponse, error)
- func (r *ApiRouter) CreateBooking(ctx context.Context, request *traits.CreateBookingRequest) (*traits.CreateBookingResponse, error)
- func (r *ApiRouter) GetBookingApiClient(name string) (traits.BookingApiClient, error)
- func (r *ApiRouter) HoldsType(client any) bool
- func (r *ApiRouter) ListBookings(ctx context.Context, request *traits.ListBookingsRequest) (*traits.ListBookingsResponse, error)
- func (r *ApiRouter) PullBookings(request *traits.ListBookingsRequest, ...) error
- func (r *ApiRouter) Register(server grpc.ServiceRegistrar)
- func (r *ApiRouter) RemoveBookingApiClient(name string) traits.BookingApiClient
- func (r *ApiRouter) UpdateBooking(ctx context.Context, request *traits.UpdateBookingRequest) (*traits.UpdateBookingResponse, error)
- type ApiWrapper
- type BookingChange
- type InfoRouter
- func (r *InfoRouter) Add(name string, client any) any
- func (r *InfoRouter) AddBookingInfoClient(name string, client traits.BookingInfoClient) traits.BookingInfoClient
- func (r *InfoRouter) DescribeBooking(ctx context.Context, request *traits.DescribeBookingRequest) (*traits.BookingSupport, error)
- func (r *InfoRouter) GetBookingInfoClient(name string) (traits.BookingInfoClient, error)
- func (r *InfoRouter) HoldsType(client any) bool
- func (r *InfoRouter) Register(server grpc.ServiceRegistrar)
- func (r *InfoRouter) RemoveBookingInfoClient(name string) traits.BookingInfoClient
- type InfoWrapper
- type Model
- func (m *Model) CreateBooking(booking *traits.Booking) (*traits.Booking, error)
- func (m *Model) ListBookings(opts ...resource.ReadOption) []*traits.Booking
- func (m *Model) PullBookings(ctx context.Context, opts ...resource.ReadOption) <-chan BookingChange
- func (m *Model) UpdateBooking(booking *traits.Booking, opts ...resource.WriteOption) (*traits.Booking, error)
- type ModelOption
- type ModelServer
- func (m *ModelServer) CheckInBooking(_ context.Context, request *traits.CheckInBookingRequest) (*traits.CheckInBookingResponse, error)
- func (m *ModelServer) CheckOutBooking(_ context.Context, request *traits.CheckOutBookingRequest) (*traits.CheckOutBookingResponse, error)
- func (m *ModelServer) CreateBooking(_ context.Context, request *traits.CreateBookingRequest) (*traits.CreateBookingResponse, error)
- func (m *ModelServer) ListBookings(_ context.Context, request *traits.ListBookingsRequest) (*traits.ListBookingsResponse, error)
- func (m *ModelServer) PullBookings(request *traits.ListBookingsRequest, ...) error
- func (m *ModelServer) Register(server grpc.ServiceRegistrar)
- func (m *ModelServer) Unwrap() any
- func (m *ModelServer) UpdateBooking(ctx context.Context, request *traits.UpdateBookingRequest) (*traits.UpdateBookingResponse, error)
Constants ¶
This section is empty.
Variables ¶
var DefaultModelOptions []resource.Option
DefaultModelOptions holds the default options for the model.
Functions ¶
func WithBookingApiClientFactory ¶
func WithBookingApiClientFactory(f func(name string) (traits.BookingApiClient, error)) router.Option
WithBookingApiClientFactory instructs the router to create a new client the first time Get is called for that name.
func WithBookingInfoClientFactory ¶
func WithBookingInfoClientFactory(f func(name string) (traits.BookingInfoClient, error)) router.Option
WithBookingInfoClientFactory instructs the router to create a new client the first time Get is called for that name.
func WithBookingOption ¶
WithBookingOption configures the booking resource of the model.
func WithInitialBooking ¶
WithInitialBooking returns an option that configures the model to initialise with the given bookings. Can be used multiple times with bookings being additive. Creating a model with duplicate booking ids will panic. Calling this function with an empty booking id property will panic.
Types ¶
type ApiRouter ¶
type ApiRouter struct { traits.UnimplementedBookingApiServer router.Router }
ApiRouter is a traits.BookingApiServer that allows routing named requests to specific traits.BookingApiClient
func NewApiRouter ¶
func (*ApiRouter) Add ¶
Add extends Router.Add to panic if client is not of type traits.BookingApiClient.
func (*ApiRouter) AddBookingApiClient ¶
func (r *ApiRouter) AddBookingApiClient(name string, client traits.BookingApiClient) traits.BookingApiClient
func (*ApiRouter) CheckInBooking ¶
func (r *ApiRouter) CheckInBooking(ctx context.Context, request *traits.CheckInBookingRequest) (*traits.CheckInBookingResponse, error)
func (*ApiRouter) CheckOutBooking ¶
func (r *ApiRouter) CheckOutBooking(ctx context.Context, request *traits.CheckOutBookingRequest) (*traits.CheckOutBookingResponse, error)
func (*ApiRouter) CreateBooking ¶
func (r *ApiRouter) CreateBooking(ctx context.Context, request *traits.CreateBookingRequest) (*traits.CreateBookingResponse, error)
func (*ApiRouter) GetBookingApiClient ¶
func (r *ApiRouter) GetBookingApiClient(name string) (traits.BookingApiClient, error)
func (*ApiRouter) ListBookings ¶
func (r *ApiRouter) ListBookings(ctx context.Context, request *traits.ListBookingsRequest) (*traits.ListBookingsResponse, error)
func (*ApiRouter) PullBookings ¶
func (r *ApiRouter) PullBookings(request *traits.ListBookingsRequest, server traits.BookingApi_PullBookingsServer) error
func (*ApiRouter) Register ¶
func (r *ApiRouter) Register(server grpc.ServiceRegistrar)
func (*ApiRouter) RemoveBookingApiClient ¶
func (r *ApiRouter) RemoveBookingApiClient(name string) traits.BookingApiClient
func (*ApiRouter) UpdateBooking ¶
func (r *ApiRouter) UpdateBooking(ctx context.Context, request *traits.UpdateBookingRequest) (*traits.UpdateBookingResponse, error)
type ApiWrapper ¶
type ApiWrapper struct { traits.BookingApiClient // contains filtered or unexported fields }
func WrapApi ¶
func WrapApi(server traits.BookingApiServer) *ApiWrapper
WrapApi adapts a traits.BookingApiServer and presents it as a traits.BookingApiClient
func (*ApiWrapper) Unwrap ¶
func (w *ApiWrapper) Unwrap() any
Unwrap implements wrap.Unwrapper and returns the underlying server instance as an unknown type.
func (*ApiWrapper) UnwrapServer ¶
func (w *ApiWrapper) UnwrapServer() traits.BookingApiServer
UnwrapServer returns the underlying server instance.
func (*ApiWrapper) UnwrapService ¶
func (w *ApiWrapper) UnwrapService() (grpc.ClientConnInterface, grpc.ServiceDesc)
type BookingChange ¶
type InfoRouter ¶
type InfoRouter struct { traits.UnimplementedBookingInfoServer router.Router }
InfoRouter is a traits.BookingInfoServer that allows routing named requests to specific traits.BookingInfoClient
func NewInfoRouter ¶
func NewInfoRouter(opts ...router.Option) *InfoRouter
func (*InfoRouter) Add ¶
func (r *InfoRouter) Add(name string, client any) any
Add extends Router.Add to panic if client is not of type traits.BookingInfoClient.
func (*InfoRouter) AddBookingInfoClient ¶
func (r *InfoRouter) AddBookingInfoClient(name string, client traits.BookingInfoClient) traits.BookingInfoClient
func (*InfoRouter) DescribeBooking ¶
func (r *InfoRouter) DescribeBooking(ctx context.Context, request *traits.DescribeBookingRequest) (*traits.BookingSupport, error)
func (*InfoRouter) GetBookingInfoClient ¶
func (r *InfoRouter) GetBookingInfoClient(name string) (traits.BookingInfoClient, error)
func (*InfoRouter) HoldsType ¶
func (r *InfoRouter) HoldsType(client any) bool
func (*InfoRouter) Register ¶
func (r *InfoRouter) Register(server grpc.ServiceRegistrar)
func (*InfoRouter) RemoveBookingInfoClient ¶
func (r *InfoRouter) RemoveBookingInfoClient(name string) traits.BookingInfoClient
type InfoWrapper ¶
type InfoWrapper struct { traits.BookingInfoClient // contains filtered or unexported fields }
func WrapInfo ¶
func WrapInfo(server traits.BookingInfoServer) *InfoWrapper
WrapInfo adapts a traits.BookingInfoServer and presents it as a traits.BookingInfoClient
func (*InfoWrapper) Unwrap ¶
func (w *InfoWrapper) Unwrap() any
Unwrap implements wrap.Unwrapper and returns the underlying server instance as an unknown type.
func (*InfoWrapper) UnwrapServer ¶
func (w *InfoWrapper) UnwrapServer() traits.BookingInfoServer
UnwrapServer returns the underlying server instance.
func (*InfoWrapper) UnwrapService ¶
func (w *InfoWrapper) UnwrapService() (grpc.ClientConnInterface, grpc.ServiceDesc)
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model models the Booking trait.
func (*Model) CreateBooking ¶
func (*Model) ListBookings ¶
func (m *Model) ListBookings(opts ...resource.ReadOption) []*traits.Booking
func (*Model) PullBookings ¶
func (m *Model) PullBookings(ctx context.Context, opts ...resource.ReadOption) <-chan BookingChange
func (*Model) UpdateBooking ¶
type ModelOption ¶
ModelOption defined the base type for all options that apply to this traits model.
type ModelServer ¶
type ModelServer struct { traits.UnimplementedBookingApiServer // contains filtered or unexported fields }
func NewModelServer ¶
func NewModelServer(model *Model) *ModelServer
func (*ModelServer) CheckInBooking ¶
func (m *ModelServer) CheckInBooking(_ context.Context, request *traits.CheckInBookingRequest) (*traits.CheckInBookingResponse, error)
func (*ModelServer) CheckOutBooking ¶
func (m *ModelServer) CheckOutBooking(_ context.Context, request *traits.CheckOutBookingRequest) (*traits.CheckOutBookingResponse, error)
func (*ModelServer) CreateBooking ¶
func (m *ModelServer) CreateBooking(_ context.Context, request *traits.CreateBookingRequest) (*traits.CreateBookingResponse, error)
func (*ModelServer) ListBookings ¶
func (m *ModelServer) ListBookings(_ context.Context, request *traits.ListBookingsRequest) (*traits.ListBookingsResponse, error)
func (*ModelServer) PullBookings ¶
func (m *ModelServer) PullBookings(request *traits.ListBookingsRequest, server traits.BookingApi_PullBookingsServer) error
func (*ModelServer) Register ¶
func (m *ModelServer) Register(server grpc.ServiceRegistrar)
func (*ModelServer) Unwrap ¶
func (m *ModelServer) Unwrap() any
func (*ModelServer) UpdateBooking ¶
func (m *ModelServer) UpdateBooking(ctx context.Context, request *traits.UpdateBookingRequest) (*traits.UpdateBookingResponse, error)