booking

package
v0.0.0-...-084e4ab Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func WithBookingOption(opts ...resource.Option) resource.Option

WithBookingOption configures the booking resource of the model.

func WithInitialBooking

func WithInitialBooking(bookings ...*traits.Booking) resource.Option

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.

func WrapApi

WrapApi adapts a traits.BookingApiServer and presents it as a traits.BookingApiClient

func WrapInfo

WrapInfo adapts a traits.BookingInfoServer and presents it as a traits.BookingInfoClient

Types

type ApiRouter

ApiRouter is a traits.BookingApiServer that allows routing named requests to specific traits.BookingApiClient

func NewApiRouter

func NewApiRouter(opts ...router.Option) *ApiRouter

func (*ApiRouter) Add

func (r *ApiRouter) Add(name string, client any) any

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 (*ApiRouter) CheckOutBooking

func (*ApiRouter) CreateBooking

func (*ApiRouter) GetBookingApiClient

func (r *ApiRouter) GetBookingApiClient(name string) (traits.BookingApiClient, error)

func (*ApiRouter) HoldsType

func (r *ApiRouter) HoldsType(client any) bool

func (*ApiRouter) ListBookings

func (*ApiRouter) PullBookings

func (*ApiRouter) Register

func (r *ApiRouter) Register(server *grpc.Server)

func (*ApiRouter) RemoveBookingApiClient

func (r *ApiRouter) RemoveBookingApiClient(name string) traits.BookingApiClient

func (*ApiRouter) UpdateBooking

type BookingChange

type BookingChange struct {
	ChangeTime time.Time
	ChangeType types.ChangeType

	OldValue, NewValue *traits.Booking
}

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.Server)

func (*InfoRouter) RemoveBookingInfoClient

func (r *InfoRouter) RemoveBookingInfoClient(name string) traits.BookingInfoClient

type Model

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

Model models the Booking trait.

func NewModel

func NewModel(opts ...resource.Option) *Model

NewModel creates a new Model without any bookings.

func (*Model) CreateBooking

func (m *Model) CreateBooking(booking *traits.Booking) (*traits.Booking, error)

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

func (m *Model) UpdateBooking(booking *traits.Booking, opts ...resource.WriteOption) (*traits.Booking, error)

type ModelOption

type ModelOption interface {
	resource.Option
	// contains filtered or unexported methods
}

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 (*ModelServer) CheckOutBooking

func (*ModelServer) CreateBooking

func (*ModelServer) ListBookings

func (*ModelServer) PullBookings

func (*ModelServer) Register

func (m *ModelServer) Register(server *grpc.Server)

func (*ModelServer) Unwrap

func (m *ModelServer) Unwrap() any

func (*ModelServer) UpdateBooking

Jump to

Keyboard shortcuts

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