hotelreservation

package
v0.0.0-...-f078915 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: BSD-3-Clause Imports: 10 Imported by: 1

README

hotelreservation

import "github.com/blueprint-uservices/blueprint/examples/dsb_hotel/workflow/hotelreservation"

Package hotelreservation implements the workflow specification of the Hotel Reservation application

Index

Constants

const (
    MAXSEARCHRESULTS = 5
    MAXSEARCHRADIUS  = 10
)

type Address

type Address struct {
    StreetNumber string
    StreetName   string
    City         string
    State        string
    Country      string
    PostalCode   string
    Lat          float64
    Lon          float64
}

type FrontEndService

FrontEndService implements the front end server from the hotel reservation application

type FrontEndService interface {
    // Returns a list of hotels that fit the search criteria provided by the user.
    SearchHandler(ctx context.Context, customerName string, inDate string, outDate string, lat float64, lon float64, locale string) ([]HotelProfile, error)
    // Returns a list of recommended hotels based on the provided location (`lat`, `lon`) and the criteria for ranking hotels (`require`)
    RecommendHandler(ctx context.Context, lat float64, lon float64, require string, locale string) ([]HotelProfile, error)
    // Logs in a user based on the username and password provided
    UserHandler(ctx context.Context, username string, password string) (string, error)
    // Makes a reservation at the user-requested hotel for the provided dates
    ReservationHandler(ctx context.Context, inDate string, outDate string, hotelId string, customerName string, username string, password string, roomNumber int64) (string, error)
}

func NewFrontEndServiceImpl
func NewFrontEndServiceImpl(ctx context.Context, searchService SearchService, profileService ProfileService, recommendationService RecommendationService, userService UserService, reservationService ReservationService) (FrontEndService, error)

Creates and Returns a new FrontEndService object

type FrontEndServiceImpl

Implementation of the FrontEndService

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

func (*FrontEndServiceImpl) RecommendHandler
func (f *FrontEndServiceImpl) RecommendHandler(ctx context.Context, lat float64, lon float64, require string, locale string) ([]HotelProfile, error)

func (*FrontEndServiceImpl) ReservationHandler
func (f *FrontEndServiceImpl) ReservationHandler(ctx context.Context, inDate string, outDate string, hotelId string, customerName string, username string, password string, roomNumber int64) (string, error)

func (*FrontEndServiceImpl) SearchHandler
func (f *FrontEndServiceImpl) SearchHandler(ctx context.Context, customerName string, inDate string, outDate string, lat float64, lon float64, locale string) ([]HotelProfile, error)

func (*FrontEndServiceImpl) UserHandler
func (f *FrontEndServiceImpl) UserHandler(ctx context.Context, username string, password string) (string, error)

type GeoService

GeoService implements the GeoService from HotelReservation

type GeoService interface {
    // Returns list of hotel IDs that are near to the provided coordinates (`lat`, `lon`)
    Nearby(ctx context.Context, lat float64, lon float64) ([]string, error)
}

func NewGeoServiceImpl
func NewGeoServiceImpl(ctx context.Context, geoDB backend.NoSQLDatabase) (GeoService, error)

Creates and returns a new GeoService object

type GeoServiceImpl

Implementation of GeoService

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

func (*GeoServiceImpl) Nearby
func (g *GeoServiceImpl) Nearby(ctx context.Context, lat float64, lon float64) ([]string, error)

type Hotel

type Hotel struct {
    HId    string
    HLat   float64
    HLon   float64
    HRate  float64
    HPrice float64
}

type HotelNumber

type HotelNumber struct {
    HotelId string
    Number  int64
}

type HotelProfile

type HotelProfile struct {
    ID          string
    Name        string
    PhoneNumber string
    Description string
    Address     Address
}

type Point

type Point struct {
    Pid  string
    Plat float64
    Plon float64
}

func (Point) Id
func (p Point) Id() string

func (Point) Lat
func (p Point) Lat() float64

func (Point) Lon
func (p Point) Lon() float64

type ProfileService

ProfileService implements Profile Service from the hotel reservation application

type ProfileService interface {
    // Returns the profiles of hotels based on the `hotelIds` provided
    GetProfiles(ctx context.Context, hotelIds []string, locale string) ([]HotelProfile, error)
}

func NewProfileServiceImpl
func NewProfileServiceImpl(ctx context.Context, profileCache backend.Cache, profileDB backend.NoSQLDatabase) (ProfileService, error)

Creates and Returns a new Profile Service object

type ProfileServiceImpl

Implementation of Profile Service

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

func (*ProfileServiceImpl) GetProfiles
func (p *ProfileServiceImpl) GetProfiles(ctx context.Context, hotelIds []string, locale string) ([]HotelProfile, error)

type RatePlan

type RatePlan struct {
    HotelID string
    Code    string
    InDate  string
    OutDate string
    RType   RoomType
}

type RateService

RateService implements Rate Service from the hotel reservation application

type RateService interface {
    // GetRates return the rates for the desired hotels (`hotelIDs`) for the provided dates (`inDate`, `outDate`)
    GetRates(ctx context.Context, hotelIDs []string, inDate string, outDate string) ([]RatePlan, error)
}

func NewRateServiceImpl
func NewRateServiceImpl(ctx context.Context, rateCache backend.Cache, rateDB backend.NoSQLDatabase) (RateService, error)

Creates and Returns a new RateService object

type RateServiceImpl

Implementation of RateService

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

func (*RateServiceImpl) GetRates
func (r *RateServiceImpl) GetRates(ctx context.Context, hotelIDs []string, inDate string, outDate string) ([]RatePlan, error)

type RecommendationService

RecommendationService implements Recommendation Service from the hotel reservation application

type RecommendationService interface {
    // Returns the recommended hotels based on the desired location (`lat`, `lon`) and the metric (`require`) for ranking recommendations
    GetRecommendations(ctx context.Context, require string, lat float64, lon float64) ([]string, error)
}

func NewRecommendationServiceImpl
func NewRecommendationServiceImpl(ctx context.Context, recommendDB backend.NoSQLDatabase) (RecommendationService, error)

Creates and Returns a new RecommendationService object

type RecommendationServiceImpl

Implements RecommendationService

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

func (*RecommendationServiceImpl) GetRecommendations
func (r *RecommendationServiceImpl) GetRecommendations(ctx context.Context, require string, lat float64, lon float64) ([]string, error)

func (*RecommendationServiceImpl) LoadRecommendations
func (r *RecommendationServiceImpl) LoadRecommendations(ctx context.Context) error

type Reservation

type Reservation struct {
    HotelId      string
    CustomerName string
    InDate       string
    OutDate      string
    Number       int64
}

type ReservationService

ReservationService implements ReservationService from hotel reservation application

type ReservationService interface {
    // Makes a reservation at the desired hotel (`hotelIds[0]`, len(hotelIds) == 1). Returns the hotelID if the reservation is successful.
    MakeReservation(ctx context.Context, customerName string, hotelIds []string, inDate string, outDate string, roomNumber int64) ([]string, error)
    // Returns the subset of hotels from desired hotels that are available for reservation
    CheckAvailability(ctx context.Context, customerName string, hotelIDs []string, inDate string, outDate string, roomNumber int64) ([]string, error)
}

func NewReservationServiceImpl
func NewReservationServiceImpl(ctx context.Context, reserveCache backend.Cache, reserveDB backend.NoSQLDatabase) (ReservationService, error)

type ReservationServiceImpl

type ReservationServiceImpl struct {
    CacheHits   int64
    NumRequests int64
    // contains filtered or unexported fields
}

func (*ReservationServiceImpl) CheckAvailability
func (r *ReservationServiceImpl) CheckAvailability(ctx context.Context, customerName string, hotelIds []string, inDate string, outDate string, roomNumber int64) ([]string, error)

func (*ReservationServiceImpl) MakeReservation
func (r *ReservationServiceImpl) MakeReservation(ctx context.Context, customerName string, hotelIds []string, inDate string, outDate string, roomNumber int64) ([]string, error)

type RoomType

type RoomType struct {
    BookableRate       float64
    Code               string
    RoomDescription    string
    TotalRate          float64
    TotalRateInclusive float64
}

type SearchService

SearchService implements the Search service from hotel reservation

type SearchService interface {
    // Returns the list of available hotels based on a given location for the desired date range
    Nearby(ctx context.Context, lat float64, lon float64, inDate string, outDate string) ([]string, error)
}

func NewSearchServiceImpl
func NewSearchServiceImpl(ctx context.Context, geoService GeoService, rateService RateService) (SearchService, error)

Creates and Returns a new SearchService object

type SearchServiceImpl

Implementation of the Search Service

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

func (*SearchServiceImpl) Nearby
func (s *SearchServiceImpl) Nearby(ctx context.Context, lat float64, lon float64, inDate string, outDate string) ([]string, error)

type User

type User struct {
    Username string
    Password string
}

type UserService

UserService manages the registered users for the application

type UserService interface {
    // Returns true if the provided credentials are for a valid user and match the stored credentials.
    // Returns false otherwise.
    CheckUser(ctx context.Context, username string, password string) (bool, error)
}

func NewUserServiceImpl
func NewUserServiceImpl(ctx context.Context, userDB backend.NoSQLDatabase) (UserService, error)

Creates and returns a new UserService object

type UserServiceImpl

Implementation of the UserService

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

func (*UserServiceImpl) CheckUser
func (u *UserServiceImpl) CheckUser(ctx context.Context, username string, password string) (bool, error)

func (*UserServiceImpl) LoadUsers
func (u *UserServiceImpl) LoadUsers(ctx context.Context) error

Generated by gomarkdoc

Documentation

Overview

Package hotelreservation implements the workflow specification of the Hotel Reservation application

Index

Constants

View Source
const (
	MAXSEARCHRESULTS = 5
	MAXSEARCHRADIUS  = 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	StreetNumber string
	StreetName   string
	City         string
	State        string
	Country      string
	PostalCode   string
	Lat          float64
	Lon          float64
}

type FrontEndService

type FrontEndService interface {
	// Returns a list of hotels that fit the search criteria provided by the user.
	SearchHandler(ctx context.Context, customerName string, inDate string, outDate string, lat float64, lon float64, locale string) ([]HotelProfile, error)
	// Returns a list of recommended hotels based on the provided location (`lat`, `lon`) and the criteria for ranking hotels (`require`)
	RecommendHandler(ctx context.Context, lat float64, lon float64, require string, locale string) ([]HotelProfile, error)
	// Logs in a user based on the username and password provided
	UserHandler(ctx context.Context, username string, password string) (string, error)
	// Makes a reservation at the user-requested hotel for the provided dates
	ReservationHandler(ctx context.Context, inDate string, outDate string, hotelId string, customerName string, username string, password string, roomNumber int64) (string, error)
}

FrontEndService implements the front end server from the hotel reservation application

func NewFrontEndServiceImpl

func NewFrontEndServiceImpl(ctx context.Context, searchService SearchService, profileService ProfileService, recommendationService RecommendationService, userService UserService, reservationService ReservationService) (FrontEndService, error)

Creates and Returns a new FrontEndService object

type FrontEndServiceImpl

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

Implementation of the FrontEndService

func (*FrontEndServiceImpl) RecommendHandler

func (f *FrontEndServiceImpl) RecommendHandler(ctx context.Context, lat float64, lon float64, require string, locale string) ([]HotelProfile, error)

func (*FrontEndServiceImpl) ReservationHandler

func (f *FrontEndServiceImpl) ReservationHandler(ctx context.Context, inDate string, outDate string, hotelId string, customerName string, username string, password string, roomNumber int64) (string, error)

func (*FrontEndServiceImpl) SearchHandler

func (f *FrontEndServiceImpl) SearchHandler(ctx context.Context, customerName string, inDate string, outDate string, lat float64, lon float64, locale string) ([]HotelProfile, error)

func (*FrontEndServiceImpl) UserHandler

func (f *FrontEndServiceImpl) UserHandler(ctx context.Context, username string, password string) (string, error)

type GeoService

type GeoService interface {
	// Returns list of hotel IDs that are near to the provided coordinates (`lat`, `lon`)
	Nearby(ctx context.Context, lat float64, lon float64) ([]string, error)
}

GeoService implements the GeoService from HotelReservation

func NewGeoServiceImpl

func NewGeoServiceImpl(ctx context.Context, geoDB backend.NoSQLDatabase) (GeoService, error)

Creates and returns a new GeoService object

type GeoServiceImpl

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

Implementation of GeoService

func (*GeoServiceImpl) Nearby

func (g *GeoServiceImpl) Nearby(ctx context.Context, lat float64, lon float64) ([]string, error)

type Hotel

type Hotel struct {
	HId    string
	HLat   float64
	HLon   float64
	HRate  float64
	HPrice float64
}

type HotelNumber

type HotelNumber struct {
	HotelId string
	Number  int64
}

type HotelProfile

type HotelProfile struct {
	ID          string
	Name        string
	PhoneNumber string
	Description string
	Address     Address
}

type Point

type Point struct {
	Pid  string
	Plat float64
	Plon float64
}

func (Point) Id

func (p Point) Id() string

func (Point) Lat

func (p Point) Lat() float64

func (Point) Lon

func (p Point) Lon() float64

type ProfileService

type ProfileService interface {
	// Returns the profiles of hotels based on the `hotelIds` provided
	GetProfiles(ctx context.Context, hotelIds []string, locale string) ([]HotelProfile, error)
}

ProfileService implements Profile Service from the hotel reservation application

func NewProfileServiceImpl

func NewProfileServiceImpl(ctx context.Context, profileCache backend.Cache, profileDB backend.NoSQLDatabase) (ProfileService, error)

Creates and Returns a new Profile Service object

type ProfileServiceImpl

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

Implementation of Profile Service

func (*ProfileServiceImpl) GetProfiles

func (p *ProfileServiceImpl) GetProfiles(ctx context.Context, hotelIds []string, locale string) ([]HotelProfile, error)

type RatePlan

type RatePlan struct {
	HotelID string
	Code    string
	InDate  string
	OutDate string
	RType   RoomType
}

type RateService

type RateService interface {
	// GetRates return the rates for the desired hotels (`hotelIDs`) for the provided dates (`inDate`, `outDate`)
	GetRates(ctx context.Context, hotelIDs []string, inDate string, outDate string) ([]RatePlan, error)
}

RateService implements Rate Service from the hotel reservation application

func NewRateServiceImpl

func NewRateServiceImpl(ctx context.Context, rateCache backend.Cache, rateDB backend.NoSQLDatabase) (RateService, error)

Creates and Returns a new RateService object

type RateServiceImpl

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

Implementation of RateService

func (*RateServiceImpl) GetRates

func (r *RateServiceImpl) GetRates(ctx context.Context, hotelIDs []string, inDate string, outDate string) ([]RatePlan, error)

type RecommendationService

type RecommendationService interface {
	// Returns the recommended hotels based on the desired location (`lat`, `lon`) and the metric (`require`) for ranking recommendations
	GetRecommendations(ctx context.Context, require string, lat float64, lon float64) ([]string, error)
}

RecommendationService implements Recommendation Service from the hotel reservation application

func NewRecommendationServiceImpl

func NewRecommendationServiceImpl(ctx context.Context, recommendDB backend.NoSQLDatabase) (RecommendationService, error)

Creates and Returns a new RecommendationService object

type RecommendationServiceImpl

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

Implements RecommendationService

func (*RecommendationServiceImpl) GetRecommendations

func (r *RecommendationServiceImpl) GetRecommendations(ctx context.Context, require string, lat float64, lon float64) ([]string, error)

func (*RecommendationServiceImpl) LoadRecommendations

func (r *RecommendationServiceImpl) LoadRecommendations(ctx context.Context) error

type Reservation

type Reservation struct {
	HotelId      string
	CustomerName string
	InDate       string
	OutDate      string
	Number       int64
}

type ReservationService

type ReservationService interface {
	// Makes a reservation at the desired hotel (`hotelIds[0]`, len(hotelIds) == 1). Returns the hotelID if the reservation is successful.
	MakeReservation(ctx context.Context, customerName string, hotelIds []string, inDate string, outDate string, roomNumber int64) ([]string, error)
	// Returns the subset of hotels from desired hotels that are available for reservation
	CheckAvailability(ctx context.Context, customerName string, hotelIDs []string, inDate string, outDate string, roomNumber int64) ([]string, error)
}

ReservationService implements ReservationService from hotel reservation application

func NewReservationServiceImpl

func NewReservationServiceImpl(ctx context.Context, reserveCache backend.Cache, reserveDB backend.NoSQLDatabase) (ReservationService, error)

type ReservationServiceImpl

type ReservationServiceImpl struct {
	CacheHits   int64
	NumRequests int64
	// contains filtered or unexported fields
}

func (*ReservationServiceImpl) CheckAvailability

func (r *ReservationServiceImpl) CheckAvailability(ctx context.Context, customerName string, hotelIds []string, inDate string, outDate string, roomNumber int64) ([]string, error)

func (*ReservationServiceImpl) MakeReservation

func (r *ReservationServiceImpl) MakeReservation(ctx context.Context, customerName string, hotelIds []string, inDate string, outDate string, roomNumber int64) ([]string, error)

type RoomType

type RoomType struct {
	BookableRate       float64
	Code               string
	RoomDescription    string
	TotalRate          float64
	TotalRateInclusive float64
}

type SearchService

type SearchService interface {
	// Returns the list of available hotels based on a given location for the desired date range
	Nearby(ctx context.Context, lat float64, lon float64, inDate string, outDate string) ([]string, error)
}

SearchService implements the Search service from hotel reservation

func NewSearchServiceImpl

func NewSearchServiceImpl(ctx context.Context, geoService GeoService, rateService RateService) (SearchService, error)

Creates and Returns a new SearchService object

type SearchServiceImpl

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

Implementation of the Search Service

func (*SearchServiceImpl) Nearby

func (s *SearchServiceImpl) Nearby(ctx context.Context, lat float64, lon float64, inDate string, outDate string) ([]string, error)

type User

type User struct {
	Username string
	Password string
}

type UserService

type UserService interface {
	// Returns true if the provided credentials are for a valid user and match the stored credentials.
	// Returns false otherwise.
	CheckUser(ctx context.Context, username string, password string) (bool, error)
}

UserService manages the registered users for the application

func NewUserServiceImpl

func NewUserServiceImpl(ctx context.Context, userDB backend.NoSQLDatabase) (UserService, error)

Creates and returns a new UserService object

type UserServiceImpl

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

Implementation of the UserService

func (*UserServiceImpl) CheckUser

func (u *UserServiceImpl) CheckUser(ctx context.Context, username string, password string) (bool, error)

func (*UserServiceImpl) LoadUsers

func (u *UserServiceImpl) LoadUsers(ctx context.Context) error

Jump to

Keyboard shortcuts

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