-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstorefront.go
36 lines (28 loc) · 883 Bytes
/
storefront.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package storefront
import (
"fmt"
"github.com/dudleycodes/golang-microservice-structure/pkg/dtos"
)
// Storefront exposes all functionalities of the Storefront service.
type Storefront interface {
GetMake(string) (dtos.Make, error)
GetModel(string) (dtos.Model, error)
Ping() bool
}
// Broker manages the internal state of the Storefront service.
type Broker struct {
cfg Config // the storefront's configuration
}
// New initializes a new Storefront service.
func New(cfg Config) (*Broker, error) {
r := &Broker{}
if err := validateConfig(cfg); err != nil {
return nil, fmt.Errorf("invalid configuration: %w", err)
}
return r, nil
}
// Ping checks to see if the storefront's database is responding.
func (brk *Broker) Ping() bool {
// This function would check the storefront's dependencies (datastores and whatnot); useful for Kubernetes probes
return true
}