Documentation ¶
Overview ¶
Package hotelreservation implements the workflow specification of the Hotel Reservation application
Index ¶
- Constants
- type Address
- type FrontEndService
- type FrontEndServiceImpl
- func (f *FrontEndServiceImpl) RecommendHandler(ctx context.Context, lat float64, lon float64, require string, locale string) ([]HotelProfile, error)
- func (f *FrontEndServiceImpl) ReservationHandler(ctx context.Context, inDate string, outDate string, hotelId string, ...) (string, error)
- func (f *FrontEndServiceImpl) SearchHandler(ctx context.Context, customerName string, inDate string, outDate string, ...) ([]HotelProfile, error)
- func (f *FrontEndServiceImpl) UserHandler(ctx context.Context, username string, password string) (string, error)
- type GeoService
- type GeoServiceImpl
- type Hotel
- type HotelNumber
- type HotelProfile
- type Point
- type ProfileService
- type ProfileServiceImpl
- type RatePlan
- type RateService
- type RateServiceImpl
- type RecommendationService
- type RecommendationServiceImpl
- type Reservation
- type ReservationService
- type ReservationServiceImpl
- type RoomType
- type SearchService
- type SearchServiceImpl
- type User
- type UserService
- type UserServiceImpl
Constants ¶
const ( MAXSEARCHRESULTS = 5 MAXSEARCHRADIUS = 10 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 (*FrontEndServiceImpl) SearchHandler ¶
func (*FrontEndServiceImpl) UserHandler ¶
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
type HotelNumber ¶
type HotelProfile ¶
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 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
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 (*RecommendationServiceImpl) LoadRecommendations ¶
func (r *RecommendationServiceImpl) LoadRecommendations(ctx context.Context) error
type Reservation ¶
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 ¶
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
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