Skip to content

Instantly share code, notes, and snippets.

@CharlesWinter
Created January 22, 2021 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save CharlesWinter/cfa269ae905b30db0ebf39b803eb347b to your computer and use it in GitHub Desktop.
Save CharlesWinter/cfa269ae905b30db0ebf39b803eb347b to your computer and use it in GitHub Desktop.
Our repository method for counting customer bookings
ackage bookings
type Repository struct {
// in reality, this client will likely be something we generate from a
// schema, or implement ourselves if needs be. Its not discussed here for
// conciseness
client bookingsServiceClient
}
type booking struct {
ID uint `json:"id"`
}
func (r *Repository) CountCustomerBookings(customerID uint) (uint, error) {
// we make a request to the bookings service here. This is done in pseudocode
// so as not to get bogged down in the details.
bookings, err := r.client.GetCustomerBookings(customerID)
var numBookings uint = len(bookings)
return numBookings, err
}
@RyanBalfanz
Copy link

RyanBalfanz commented Jan 30, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment