Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
James Tran committed Aug 12, 2022
1 parent 8582d04 commit 26475ea
Show file tree
Hide file tree
Showing 16 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

func main() {
err := config.Engine.VerifyConfigurations()
fmt.Println(err)
fmt.Println("Engine configuration error:", err)

testEngine()
}
Expand Down
2 changes: 1 addition & 1 deletion sample/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var Engine = &CostEngine{
Engine: cte.NewEngine(),
}

var printDebugLog = false
var printDebugLog = true

func Print(values ...any) {
if printDebugLog {
Expand Down
4 changes: 2 additions & 2 deletions sample/service/components/costconfigs/computer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import (
type computer struct{}

func (c computer) Compute(ctx context.Context, p cte.MasterPlan) (any, error) {
casted := p.(plan)
casted := p.(inout)

return c.doFetch(casted), nil
}

func (c computer) doFetch(p plan) configsfetcher.MergedCostConfigs {
func (c computer) doFetch(p inout) configsfetcher.MergedCostConfigs {
return p.GetConfigsFetcher().Fetch()
}
4 changes: 2 additions & 2 deletions sample/service/components/costconfigs/inout.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/jamestrandung/go-cte/sample/dependencies/configsfetcher"
)

type plan interface {
type inout interface {
Dependencies
}

Expand All @@ -18,7 +18,7 @@ type CostConfigs cte.Result
func (c CostConfigs) CTEMetadata() any {
return struct {
computer computer
inout plan
inout inout
}{}
}

Expand Down
4 changes: 2 additions & 2 deletions sample/service/components/platformfee/computer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (
type computer struct{}

func (c computer) Compute(ctx context.Context, p cte.MasterPlan) error {
casted := p.(plan)
casted := p.(inout)

c.addPlatformFee(casted)

return nil
}

func (computer) addPlatformFee(p plan) {
func (computer) addPlatformFee(p inout) {
p.SetTotalCost(p.GetTotalCost() + p.GetPlatformFee())
}
4 changes: 2 additions & 2 deletions sample/service/components/platformfee/inout.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package platformfee

import "github.com/jamestrandung/go-cte/cte"

type plan interface {
type inout interface {
Input
Output
}
Expand All @@ -21,6 +21,6 @@ type PlatformFee cte.SyncSideEffect
func (c PlatformFee) CTEMetadata() any {
return struct {
computer computer
inout plan
inout inout
}{}
}
2 changes: 1 addition & 1 deletion sample/service/components/quote/computer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type computer struct{}

// TODO: Due to pre execution can return nil, clients must take care of handling nil plan in getters
func (c computer) Switch(ctx context.Context, p cte.MasterPlan) (cte.MasterPlan, error) {
casted := p.(plan)
casted := p.(inout)

if casted.GetIsFixedCostEnabled() {
return fixedcost.NewPlan(casted), nil
Expand Down
4 changes: 2 additions & 2 deletions sample/service/components/quote/inout.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/jamestrandung/go-cte/sample/service/scaffolding/fixedcost"
)

type plan interface {
type inout interface {
Input
}

Expand All @@ -26,7 +26,7 @@ type FixedCostBranch cte.Result
func (c FixedCostBranch) CTEMetadata() any {
return struct {
computer computer
inout plan
inout inout
}{}
}

Expand Down
4 changes: 2 additions & 2 deletions sample/service/components/streaming/computer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (
type computer struct{}

func (c computer) Compute(ctx context.Context, p cte.MasterPlan) error {
casted := p.(plan)
casted := p.(inout)

c.stream(casted)

return nil
}

func (computer) stream(p plan) {
func (computer) stream(p inout) {
config.Print("Streaming calculated cost:", p.GetTotalCost())
}
4 changes: 2 additions & 2 deletions sample/service/components/streaming/inout.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package streaming

import "github.com/jamestrandung/go-cte/cte"

type plan interface {
type inout interface {
Input
}

Expand All @@ -15,6 +15,6 @@ type CostStreaming cte.SideEffect
func (c CostStreaming) CTEMetadata() any {
return struct {
computer computer
inout plan
inout inout
}{}
}
2 changes: 1 addition & 1 deletion sample/service/components/travelcost/computer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
type Computer struct{}

func (c Computer) Compute(ctx context.Context, p cte.MasterPlan) (any, error) {
casted := p.(plan)
casted := p.(inout)

return c.calculateTravelCost(casted), nil
}
Expand Down
4 changes: 2 additions & 2 deletions sample/service/components/travelcost/inout.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/jamestrandung/go-cte/cte"
)

type plan interface {
type inout interface {
Input
}

Expand All @@ -21,7 +21,7 @@ type TravelCost cte.Result
func (r TravelCost) CTEMetadata() any {
return struct {
computer Computer
inout plan
inout inout
}{}
}

Expand Down
4 changes: 2 additions & 2 deletions sample/service/components/travelplan/computer.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
type computer struct{}

func (c computer) Compute(ctx context.Context, p cte.MasterPlan) (any, error) {
casted := p.(plan)
casted := p.(inout)

route, err := casted.GetMapService().GetRoute(casted.GetPointA(), casted.GetPointB())
if err != nil {
Expand All @@ -23,7 +23,7 @@ func (c computer) Compute(ctx context.Context, p cte.MasterPlan) (any, error) {
return route, nil
}

func (c computer) calculateStraightLineDistance(p plan) mapservice.Route {
func (c computer) calculateStraightLineDistance(p inout) mapservice.Route {
config.Printf("Building route from %s to %s using straight-line distance\n", p.GetPointA(), p.GetPointB())
return mapservice.Route{
Distance: 4,
Expand Down
4 changes: 2 additions & 2 deletions sample/service/components/travelplan/inout.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/jamestrandung/go-cte/sample/dependencies/mapservice"
)

type plan interface {
type inout interface {
Input
}

Expand All @@ -24,7 +24,7 @@ type TravelPlan cte.Result
func (p TravelPlan) CTEMetadata() any {
return struct {
computer computer
inout plan
inout inout
}{}
}

Expand Down
2 changes: 1 addition & 1 deletion sample/service/components/vat/computer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
type computer struct{}

func (c computer) Compute(ctx context.Context, p cte.MasterPlan) (any, error) {
casted := p.(plan)
casted := p.(inout)

vatAmount := casted.GetTotalCost() * casted.GetVATPercent() / 100
casted.SetTotalCost(casted.GetTotalCost() + vatAmount)
Expand Down
4 changes: 2 additions & 2 deletions sample/service/components/vat/inout.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/jamestrandung/go-cte/cte"
)

type plan interface {
type inout interface {
Input
Output
}
Expand All @@ -23,7 +23,7 @@ type VATAmount cte.SyncResult
func (a VATAmount) CTEMetadata() any {
return struct {
computer computer
inout plan
inout inout
}{}
}

Expand Down

0 comments on commit 26475ea

Please sign in to comment.