internal

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2020 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	DSN           string `envconfig:"DSN" required:"false" default:"postgres://postgres:postgres@localhost:5432/tax_service?sslmode=disable"`
	MetricsPort   int    `envconfig:"METRICS_PORT" required:"false" default:"8080"`
	MicroSelector string `envconfig:"MICRO_SELECTOR" required:"false" default:"static"`
}

Config holds default configuration options for service.

func LoadConfig

func LoadConfig() (*Config, error)

LoadConfig load config object from env.

type Service

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

Service is application entry point.s

func NewService

func NewService(db *gorm.DB) (*Service, error)

NewService create new Service.

func (*Service) CreateOrUpdate

func (s *Service) CreateOrUpdate(ctx context.Context, req *tax_service.TaxRate, res *tax_service.TaxRate) error

CreateOrUpdate used to create new or updated existing Tax record in database.

func (*Service) DeleteRateById

DeleteRateById mark Tax record as deleted in database.

func (*Service) GetRate

func (s *Service) GetRate(ctx context.Context, req *tax_service.GeoIdentity, res *tax_service.TaxRate) error

GetRate returns one single Tax record by given user provided and ip based geo information.

func (*Service) GetRates

GetRates return list of Tax from database based on provided filters.

func (*Service) Status

func (s *Service) Status() (interface{}, error)

Status used to return micro service health.

type Tax

type Tax struct {
	ID        uint32  `gorm:"primary_key"`
	Zip       string  `gorm:"type:varchar(5);unique_index:idx_primary"`
	Country   string  `gorm:"type:varchar(2);not null;unique_index:idx_primary"`
	City      string  `gorm:"type:varchar(100);unique_index:idx_primary"`
	State     string  `gorm:"type:varchar(2);unique_index:idx_primary"`
	Rate      float64 `gorm:"type:decimal(20,8);not null"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time `sql:"index"`
}

Tax defines one tax record in service database.

Jump to

Keyboard shortcuts

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