service

package
v0.0.0-...-7d965fe Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package service ...

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config func(*Services) error

Config is used for determing use of which services and db

func WithMenu

func WithMenu() Config

WithMenu is used for calling NewMenuService with a specific db

func WithOrder

func WithOrder() Config

WithOrder is used for calling NewOrderService with a specific db

func WithSqlite

func WithSqlite(path string) Config

WithSqlite takes in a path and opens the database

type MenuDB interface {
	SeedMenu(context.Context) error
	CreateMenuItem(context.Context, *pb.MenuItem) (int64, error)
	DeleteMenuItem(context.Context, int64) error
	UpdateMenuItem(context.Context, *pb.MenuItem) error
	// CreateMenuItemOption() error
	GetMenu(context.Context) (*pb.Menu, error)
}

MenuDB is everything that interacts with the database involving the menu

type MenuService interface {
	MenuDB
}

MenuService the the abstraction for the MenuDB

func NewMenuService

func NewMenuService(db *sql.DB) (MenuService, error)

NewMenuService creates a menu service for interacting with the database

type OrderDB

type OrderDB interface {
	GetOrders(context.Context) ([]*pb.Order, error)
	CompleteOrder(context.Context, int64) error
	SubmitOrder(context.Context, *pb.Order) error
}

OrderDB is everything that interacts with the database involving the orders

type OrderService

type OrderService interface {
	OrderDB
}

OrderService is the abstraction of the db layer

func NewOrderService

func NewOrderService(db *sql.DB) (OrderService, error)

NewOrderService creates a new order service for interacting with the database

type Services

type Services struct {
	Order OrderService
	Menu  MenuService
	// contains filtered or unexported fields
}

Services is the implementation of both the Menu and Order service for interacting with the database as well as the databse itself

func NewServices

func NewServices(cfgs ...Config) (*Services, error)

NewServices creates a Service struct with all of the ServiceConfigs passed into it

func (*Services) Close

func (s *Services) Close() error

Close closes the current database

Jump to

Keyboard shortcuts

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