From ece24f088a570fdfb2209db9abb175692940f657 Mon Sep 17 00:00:00 2001 From: Wes Date: Wed, 14 Feb 2024 12:52:01 -0700 Subject: [PATCH] chore: remove duplicate examples that moved to ftl-examples repo (#937) --- examples/go/httpingress/ftl.toml | 2 - examples/go/httpingress/go.mod | 45 --- examples/go/httpingress/go.sum | 143 ---------- examples/go/httpingress/httpingress.go | 115 -------- examples/go/time/go.mod | 2 +- examples/kotlin/ftl-module-ad/pom.xml | 197 ------------- .../src/main/kotlin/ftl/ad/Ad.kt | 59 ---- examples/kotlin/ftl-module-api/ftl.toml | 2 - .../src/main/kotlin/ftl/api/Api.kt | 99 ------- .../ftl.toml | 2 +- .../pom.xml | 4 +- .../src/main/kotlin/ftl/time/Time.kt | 14 + examples/kotlin/pom.xml | 2 +- examples/online-boutique/README.md | 3 - examples/online-boutique/common/database.go | 13 - .../online-boutique/common/money/money.go | 133 --------- .../common/money/money_test.go | 245 ----------------- examples/online-boutique/demo.proto | 260 ------------------ examples/online-boutique/go.mod | 5 - examples/online-boutique/go.sum | 0 examples/online-boutique/services/ad/ad.go | 67 ----- .../online-boutique/services/ad/database.json | 26 -- examples/online-boutique/services/ad/ftl.toml | 2 - examples/online-boutique/services/ad/go.mod | 12 - examples/online-boutique/services/ad/go.sum | 2 - .../online-boutique/services/cart/cart.go | 62 ----- .../online-boutique/services/cart/ftl.toml | 2 - examples/online-boutique/services/cart/go.mod | 9 - examples/online-boutique/services/cart/go.sum | 2 - .../online-boutique/services/cart/store.go | 63 ----- .../services/checkout/checkout.go | 138 ---------- .../services/checkout/ftl.toml | 2 - .../online-boutique/services/checkout/go.mod | 50 ---- .../online-boutique/services/checkout/go.sum | 143 ---------- .../services/currency/currency.go | 90 ------ .../services/currency/database.json | 35 --- .../services/currency/ftl.toml | 2 - .../online-boutique/services/currency/go.mod | 12 - .../online-boutique/services/currency/go.sum | 2 - .../online-boutique/services/payment/ftl.toml | 2 - .../online-boutique/services/payment/go.mod | 9 - .../online-boutique/services/payment/go.sum | 2 - .../services/payment/payment.go | 89 ------ .../services/productcatalog/database.json | 110 -------- .../services/productcatalog/ftl.toml | 2 - .../services/productcatalog/go.mod | 9 - .../services/productcatalog/productcatalog.go | 81 ------ .../services/recommendation/ftl.toml | 2 - .../services/recommendation/go.mod | 47 ---- .../services/recommendation/go.sum | 143 ---------- .../services/recommendation/recommendation.go | 58 ---- .../services/shipping/ftl.toml | 2 - .../online-boutique/services/shipping/go.mod | 7 - .../services/shipping/shipping.go | 51 ---- .../services/shipping/tracking.go | 47 ---- 55 files changed, 19 insertions(+), 2708 deletions(-) delete mode 100644 examples/go/httpingress/ftl.toml delete mode 100644 examples/go/httpingress/go.mod delete mode 100644 examples/go/httpingress/go.sum delete mode 100644 examples/go/httpingress/httpingress.go delete mode 100644 examples/kotlin/ftl-module-ad/pom.xml delete mode 100644 examples/kotlin/ftl-module-ad/src/main/kotlin/ftl/ad/Ad.kt delete mode 100644 examples/kotlin/ftl-module-api/ftl.toml delete mode 100644 examples/kotlin/ftl-module-api/src/main/kotlin/ftl/api/Api.kt rename examples/kotlin/{ftl-module-ad => ftl-module-time}/ftl.toml (55%) rename examples/kotlin/{ftl-module-api => ftl-module-time}/pom.xml (94%) create mode 100644 examples/kotlin/ftl-module-time/src/main/kotlin/ftl/time/Time.kt delete mode 100644 examples/online-boutique/README.md delete mode 100644 examples/online-boutique/common/database.go delete mode 100644 examples/online-boutique/common/money/money.go delete mode 100644 examples/online-boutique/common/money/money_test.go delete mode 100644 examples/online-boutique/demo.proto delete mode 100644 examples/online-boutique/go.mod delete mode 100644 examples/online-boutique/go.sum delete mode 100644 examples/online-boutique/services/ad/ad.go delete mode 100644 examples/online-boutique/services/ad/database.json delete mode 100644 examples/online-boutique/services/ad/ftl.toml delete mode 100644 examples/online-boutique/services/ad/go.mod delete mode 100644 examples/online-boutique/services/ad/go.sum delete mode 100644 examples/online-boutique/services/cart/cart.go delete mode 100644 examples/online-boutique/services/cart/ftl.toml delete mode 100644 examples/online-boutique/services/cart/go.mod delete mode 100644 examples/online-boutique/services/cart/go.sum delete mode 100644 examples/online-boutique/services/cart/store.go delete mode 100644 examples/online-boutique/services/checkout/checkout.go delete mode 100644 examples/online-boutique/services/checkout/ftl.toml delete mode 100644 examples/online-boutique/services/checkout/go.mod delete mode 100644 examples/online-boutique/services/checkout/go.sum delete mode 100644 examples/online-boutique/services/currency/currency.go delete mode 100644 examples/online-boutique/services/currency/database.json delete mode 100644 examples/online-boutique/services/currency/ftl.toml delete mode 100644 examples/online-boutique/services/currency/go.mod delete mode 100644 examples/online-boutique/services/currency/go.sum delete mode 100644 examples/online-boutique/services/payment/ftl.toml delete mode 100644 examples/online-boutique/services/payment/go.mod delete mode 100644 examples/online-boutique/services/payment/go.sum delete mode 100644 examples/online-boutique/services/payment/payment.go delete mode 100644 examples/online-boutique/services/productcatalog/database.json delete mode 100644 examples/online-boutique/services/productcatalog/ftl.toml delete mode 100644 examples/online-boutique/services/productcatalog/go.mod delete mode 100644 examples/online-boutique/services/productcatalog/productcatalog.go delete mode 100644 examples/online-boutique/services/recommendation/ftl.toml delete mode 100644 examples/online-boutique/services/recommendation/go.mod delete mode 100644 examples/online-boutique/services/recommendation/go.sum delete mode 100644 examples/online-boutique/services/recommendation/recommendation.go delete mode 100644 examples/online-boutique/services/shipping/ftl.toml delete mode 100644 examples/online-boutique/services/shipping/go.mod delete mode 100644 examples/online-boutique/services/shipping/shipping.go delete mode 100644 examples/online-boutique/services/shipping/tracking.go diff --git a/examples/go/httpingress/ftl.toml b/examples/go/httpingress/ftl.toml deleted file mode 100644 index 6e818fb41..000000000 --- a/examples/go/httpingress/ftl.toml +++ /dev/null @@ -1,2 +0,0 @@ -module = "httpingress" -language = "go" diff --git a/examples/go/httpingress/go.mod b/examples/go/httpingress/go.mod deleted file mode 100644 index bf45f39b7..000000000 --- a/examples/go/httpingress/go.mod +++ /dev/null @@ -1,45 +0,0 @@ -module ftl/httpingress - -go 1.22.0 - -replace github.com/TBD54566975/ftl => ../../.. - -require github.com/TBD54566975/ftl v0.0.0-00010101000000-000000000000 - -require ( - connectrpc.com/connect v1.14.0 // indirect - connectrpc.com/grpcreflect v1.2.0 // indirect - connectrpc.com/otelconnect v0.7.0 // indirect - github.com/alecthomas/concurrency v0.0.2 // indirect - github.com/alecthomas/participle/v2 v2.1.1 // indirect - github.com/alecthomas/types v0.10.1 // indirect - github.com/alessio/shellescape v1.4.2 // indirect - github.com/danieljoos/wincred v1.2.0 // indirect - github.com/go-logr/logr v1.4.1 // indirect - github.com/go-logr/stdr v1.2.2 // indirect - github.com/godbus/dbus/v5 v5.1.0 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/jackc/pgpassfile v1.0.0 // indirect - github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect - github.com/jackc/pgx/v5 v5.5.3 // indirect - github.com/jackc/puddle/v2 v2.2.1 // indirect - github.com/jpillora/backoff v1.0.0 // indirect - github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect - github.com/oklog/ulid/v2 v2.1.0 // indirect - github.com/swaggest/jsonschema-go v0.3.64 // indirect - github.com/swaggest/refl v1.3.0 // indirect - github.com/zalando/go-keyring v0.2.3 // indirect - go.opentelemetry.io/otel v1.23.1 // indirect - go.opentelemetry.io/otel/metric v1.23.1 // indirect - go.opentelemetry.io/otel/trace v1.23.1 // indirect - golang.design/x/reflect v0.0.0-20220504060917-02c43be63f3b // indirect - golang.org/x/crypto v0.19.0 // indirect - golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 // indirect - golang.org/x/mod v0.15.0 // indirect - golang.org/x/net v0.21.0 // indirect - golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/text v0.14.0 // indirect - google.golang.org/protobuf v1.32.0 // indirect -) diff --git a/examples/go/httpingress/go.sum b/examples/go/httpingress/go.sum deleted file mode 100644 index 1650df7dd..000000000 --- a/examples/go/httpingress/go.sum +++ /dev/null @@ -1,143 +0,0 @@ -connectrpc.com/connect v1.14.0 h1:PDS+J7uoz5Oui2VEOMcfz6Qft7opQM9hPiKvtGC01pA= -connectrpc.com/connect v1.14.0/go.mod h1:uoAq5bmhhn43TwhaKdGKN/bZcGtzPW1v+ngDTn5u+8s= -connectrpc.com/grpcreflect v1.2.0 h1:Q6og1S7HinmtbEuBvARLNwYmTbhEGRpHDhqrPNlmK+U= -connectrpc.com/grpcreflect v1.2.0/go.mod h1:nwSOKmE8nU5u/CidgHtPYk1PFI3U9ignz7iDMxOYkSY= -connectrpc.com/otelconnect v0.7.0 h1:ZH55ZZtcJOTKWWLy3qmL4Pam4RzRWBJFOqTPyAqCXkY= -connectrpc.com/otelconnect v0.7.0/go.mod h1:Bt2ivBymHZHqxvo4HkJ0EwHuUzQN6k2l0oH+mp/8nwc= -github.com/alecthomas/assert/v2 v2.5.0 h1:OJKYg53BQx06/bMRBSPDCO49CbCDNiUQXwdoNrt6x5w= -github.com/alecthomas/assert/v2 v2.5.0/go.mod h1:fw5suVxB+wfYJ3291t0hRTqtGzFYdSwstnRQdaQx2DM= -github.com/alecthomas/concurrency v0.0.2 h1:Q3kGPtLbleMbH9lHX5OBFvJygfyFw29bXZKBg+IEVuo= -github.com/alecthomas/concurrency v0.0.2/go.mod h1:GmuQb/iHX7mbNtPlC/WDzEFxDMB0HYFer2Qda9QTs7w= -github.com/alecthomas/participle/v2 v2.1.1 h1:hrjKESvSqGHzRb4yW1ciisFJ4p3MGYih6icjJvbsmV8= -github.com/alecthomas/participle/v2 v2.1.1/go.mod h1:Y1+hAs8DHPmc3YUFzqllV+eSQ9ljPTk0ZkPMtEdAx2c= -github.com/alecthomas/repr v0.3.0 h1:NeYzUPfjjlqHY4KtzgKJiWd6sVq2eNUPTi34PiFGjY8= -github.com/alecthomas/repr v0.3.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= -github.com/alecthomas/types v0.10.1 h1:PuBMoHpFL2jaW3VgPDRhCk1oKoBCzfbsL5sAxEc3U3A= -github.com/alecthomas/types v0.10.1/go.mod h1:fIOGnLeeUJXe1AAVofQmMaEMWLxY9bK4QxTLGIo30PA= -github.com/alessio/shellescape v1.4.2 h1:MHPfaU+ddJ0/bYWpgIeUnQUqKrlJ1S7BfEYPM4uEoM0= -github.com/alessio/shellescape v1.4.2/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30= -github.com/bool64/dev v0.2.31 h1:OS57EqYaYe2M/2bw9uhDCIFiZZwywKFS/4qMLN6JUmQ= -github.com/bool64/dev v0.2.31/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8ACg= -github.com/bool64/shared v0.1.5 h1:fp3eUhBsrSjNCQPcSdQqZxxh9bBwrYiZ+zOKFkM0/2E= -github.com/bool64/shared v0.1.5/go.mod h1:081yz68YC9jeFB3+Bbmno2RFWvGKv1lPKkMP6MHJlPs= -github.com/danieljoos/wincred v1.2.0 h1:ozqKHaLK0W/ii4KVbbvluM91W2H3Sh0BncbUNPS7jLE= -github.com/danieljoos/wincred v1.2.0/go.mod h1:FzQLLMKBFdvu+osBrnFODiv32YGwCfx0SkRa/eYHgec= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= -github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= -github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= -github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= -github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= -github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= -github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc= -github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE= -github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= -github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= -github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk= -github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= -github.com/jackc/pgx/v5 v5.5.3 h1:Ces6/M3wbDXYpM8JyyPD57ivTtJACFZJd885pdIaV2s= -github.com/jackc/pgx/v5 v5.5.3/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A= -github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk= -github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= -github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA= -github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= -github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= -github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/oklog/ulid/v2 v2.1.0 h1:+9lhoxAP56we25tyYETBBY1YLA2SaoLvUFgrP2miPJU= -github.com/oklog/ulid/v2 v2.1.0/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ= -github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= -github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= -github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 h1:lZUw3E0/J3roVtGQ+SCrUrg3ON6NgVqpn3+iol9aGu4= -github.com/santhosh-tekuri/jsonschema/v5 v5.3.1/go.mod h1:uToXkOrWAZ6/Oc07xWQrPOhJotwFIyu2bBVN41fcDUY= -github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= -github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/swaggest/assertjson v1.9.0 h1:dKu0BfJkIxv/xe//mkCrK5yZbs79jL7OVf9Ija7o2xQ= -github.com/swaggest/assertjson v1.9.0/go.mod h1:b+ZKX2VRiUjxfUIal0HDN85W0nHPAYUbYH5WkkSsFsU= -github.com/swaggest/jsonschema-go v0.3.64 h1:HyB41fkA4XP0BZkqWfGap5i2JtRHQGXG/21dGDPbyLM= -github.com/swaggest/jsonschema-go v0.3.64/go.mod h1:DYuKqdpms/edvywsX6p1zHXCZkdwB28wRaBdFCe3Duw= -github.com/swaggest/refl v1.3.0 h1:PEUWIku+ZznYfsoyheF97ypSduvMApYyGkYF3nabS0I= -github.com/swaggest/refl v1.3.0/go.mod h1:3Ujvbmh1pfSbDYjC6JGG7nMgPvpG0ehQL4iNonnLNbg= -github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCOA= -github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= -github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3IfnEUduWvb9is428/nNb5L3U01M= -github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= -github.com/zalando/go-keyring v0.2.3 h1:v9CUu9phlABObO4LPWycf+zwMG7nlbb3t/B5wa97yms= -github.com/zalando/go-keyring v0.2.3/go.mod h1:HL4k+OXQfJUWaMnqyuSOc0drfGPX2b51Du6K+MRgZMk= -go.opentelemetry.io/otel v1.23.1 h1:Za4UzOqJYS+MUczKI320AtqZHZb7EqxO00jAHE0jmQY= -go.opentelemetry.io/otel v1.23.1/go.mod h1:Td0134eafDLcTS4y+zQ26GE8u3dEuRBiBCTUIRHaikA= -go.opentelemetry.io/otel/metric v1.23.1 h1:PQJmqJ9u2QaJLBOELl1cxIdPcpbwzbkjfEyelTl2rlo= -go.opentelemetry.io/otel/metric v1.23.1/go.mod h1:mpG2QPlAfnK8yNhNJAxDZruU9Y1/HubbC+KyH8FaCWI= -go.opentelemetry.io/otel/sdk v1.23.1 h1:O7JmZw0h76if63LQdsBMKQDWNb5oEcOThG9IrxscV+E= -go.opentelemetry.io/otel/sdk v1.23.1/go.mod h1:LzdEVR5am1uKOOwfBWFef2DCi1nu3SA8XQxx2IerWFk= -go.opentelemetry.io/otel/sdk/metric v1.23.1 h1:T9/8WsYg+ZqIpMWwdISVVrlGb/N0Jr1OHjR/alpKwzg= -go.opentelemetry.io/otel/sdk/metric v1.23.1/go.mod h1:8WX6WnNtHCgUruJ4TJ+UssQjMtpxkpX0zveQC8JG/E0= -go.opentelemetry.io/otel/trace v1.23.1 h1:4LrmmEd8AU2rFvU1zegmvqW7+kWarxtNOPyeL6HmYY8= -go.opentelemetry.io/otel/trace v1.23.1/go.mod h1:4IpnpJFwr1mo/6HL8XIPJaE9y0+u1KcVmuW7dwFSVrI= -golang.design/x/reflect v0.0.0-20220504060917-02c43be63f3b h1:lkOPTy76R9NZ6FeDQWkDj3NsLtD8Csc9AAFYEl3kiME= -golang.design/x/reflect v0.0.0-20220504060917-02c43be63f3b/go.mod h1:QXG482h3unP32W/YwIPOc+09bvY447B7T+iLjC/JPcA= -golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= -golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= -golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 h1:/RIbNt/Zr7rVhIkQhooTxCxFcdWLGIKnZA4IXNFSrvo= -golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= -golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= -golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= -golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= -google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= -google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -lukechampine.com/uint128 v1.2.0 h1:mBi/5l91vocEN8otkC5bDLhi2KdCticRiwbdB0O+rjI= -lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= -modernc.org/cc/v3 v3.40.0 h1:P3g79IUS/93SYhtoeaHW+kRCIrYaxJ27MFPv+7kaTOw= -modernc.org/cc/v3 v3.40.0/go.mod h1:/bTg4dnWkSXowUO6ssQKnOV0yMVxDYNIsIrzqTFDGH0= -modernc.org/ccgo/v3 v3.16.13 h1:Mkgdzl46i5F/CNR/Kj80Ri59hC8TKAhZrYSaqvkwzUw= -modernc.org/ccgo/v3 v3.16.13/go.mod h1:2Quk+5YgpImhPjv2Qsob1DnZ/4som1lJTodubIcoUkY= -modernc.org/libc v1.29.0 h1:tTFRFq69YKCF2QyGNuRUQxKBm1uZZLubf6Cjh/pVHXs= -modernc.org/libc v1.29.0/go.mod h1:DaG/4Q3LRRdqpiLyP0C2m1B8ZMGkQ+cCgOIjEtQlYhQ= -modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4= -modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo= -modernc.org/memory v1.7.2 h1:Klh90S215mmH8c9gO98QxQFsY+W451E8AnzjoE2ee1E= -modernc.org/memory v1.7.2/go.mod h1:NO4NVCQy0N7ln+T9ngWqOQfi7ley4vpwvARR+Hjw95E= -modernc.org/opt v0.1.3 h1:3XOZf2yznlhC+ibLltsDGzABUGVx8J6pnFMS3E4dcq4= -modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= -modernc.org/sqlite v1.28.0 h1:Zx+LyDDmXczNnEQdvPuEfcFVA2ZPyaD7UCZDjef3BHQ= -modernc.org/sqlite v1.28.0/go.mod h1:Qxpazz0zH8Z1xCFyi5GSL3FzbtZ3fvbjmywNogldEW0= -modernc.org/strutil v1.1.3 h1:fNMm+oJklMGYfU9Ylcywl0CO5O6nTfaowNsh2wpPjzY= -modernc.org/strutil v1.1.3/go.mod h1:MEHNA7PdEnEwLvspRMtWTNnp2nnyvMfkimT1NKNAGbw= -modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y= -modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= diff --git a/examples/go/httpingress/httpingress.go b/examples/go/httpingress/httpingress.go deleted file mode 100644 index 22ea51525..000000000 --- a/examples/go/httpingress/httpingress.go +++ /dev/null @@ -1,115 +0,0 @@ -//ftl:module httpingress -package httpingress - -import ( - "context" - "fmt" - - "ftl/builtin" - - "github.com/TBD54566975/ftl/go-runtime/ftl" -) - -type GetRequest struct { - UserID string `alias:"userId"` - PostID string `alias:"postId"` -} - -type Nested struct { - GoodStuff string `alias:"good_stuff"` -} - -type GetResponse struct { - Message string `alias:"random"` - Nested Nested `alias:"nested"` -} - -// Example: curl -i http://localhost:8892/ingress/http/users/123/posts?postId=456 -// -//ftl:verb -//ftl:ingress http GET /http/users/{userID}/posts -func Get(ctx context.Context, req builtin.HttpRequest[GetRequest]) (builtin.HttpResponse[GetResponse, ftl.Unit], error) { - return builtin.HttpResponse[GetResponse, ftl.Unit]{ - Headers: map[string][]string{"Get": {"Header from FTL"}}, - Body: ftl.Some(GetResponse{ - Message: fmt.Sprintf("Got userId %s and postId %s", req.Body.UserID, req.Body.PostID), - Nested: Nested{GoodStuff: "Nested Good Stuff"}, - }), - }, nil -} - -type PostRequest struct { - UserID int `alias:"user_id"` - PostID int `alias:"post_id"` -} - -type PostResponse struct { - Success bool `alias:"success"` -} - -// Example: curl -i --json '{"user_id": 123, "post_id": 345}' http://localhost:8892/ingress/http/users -// -//ftl:verb -//ftl:ingress http POST /http/users -func Post(ctx context.Context, req builtin.HttpRequest[PostRequest]) (builtin.HttpResponse[PostResponse, ftl.Unit], error) { - return builtin.HttpResponse[PostResponse, ftl.Unit]{ - Status: 201, - Headers: map[string][]string{"Post": {"Header from FTL"}}, - Body: ftl.Some(PostResponse{Success: true}), - }, nil -} - -type PutRequest struct { - UserID string `alias:"userId"` - PostID string `alias:"postId"` -} - -type PutResponse struct{} - -// Example: curl -X PUT http://localhost:8892/ingress/http/users/123 -d '{"postID": "123"}' -// -//ftl:verb -//ftl:ingress http PUT /http/users/{userID} -func Put(ctx context.Context, req builtin.HttpRequest[PutRequest]) (builtin.HttpResponse[PutResponse, ftl.Unit], error) { - return builtin.HttpResponse[PutResponse, ftl.Unit]{ - Headers: map[string][]string{"Put": {"Header from FTL"}}, - }, nil -} - -type DeleteRequest struct { - UserID string `alias:"userId"` -} - -type DeleteResponse struct{} - -// Example: curl -X DELETE http://localhost:8892/ingress/http/users/123 -// -//ftl:verb -//ftl:ingress http DELETE /http/users/{userID} -func Delete(ctx context.Context, req builtin.HttpRequest[DeleteRequest]) (builtin.HttpResponse[DeleteResponse, ftl.Unit], error) { - return builtin.HttpResponse[DeleteResponse, ftl.Unit]{ - Headers: map[string][]string{"Put": {"Header from FTL"}}, - }, nil -} - -type HtmlRequest struct{} - -//ftl:verb -//ftl:ingress http GET /http/html -func Html(ctx context.Context, req builtin.HttpRequest[HtmlRequest]) (builtin.HttpResponse[string, ftl.Unit], error) { - return builtin.HttpResponse[string, ftl.Unit]{ - Headers: map[string][]string{"Content-Type": {"text/html; charset=utf-8"}}, - Body: ftl.Some("

HTML Page From FTL 🚀!

"), - }, nil -} - -// Example: curl -X POST http://localhost:8892/ingress/http/bytes -d 'Your data here' -// -//ftl:verb -//ftl:ingress http POST /http/bytes -func Bytes(ctx context.Context, req builtin.HttpRequest[[]byte]) (builtin.HttpResponse[[]byte, ftl.Unit], error) { - return builtin.HttpResponse[[]byte, ftl.Unit]{ - Headers: map[string][]string{"Content-Type": {"application/octet-stream"}}, - Body: ftl.Some(req.Body), - }, nil -} diff --git a/examples/go/time/go.mod b/examples/go/time/go.mod index d740551ce..ac4396a52 100644 --- a/examples/go/time/go.mod +++ b/examples/go/time/go.mod @@ -1,5 +1,5 @@ module ftl/time -go 1.21.6 +go 1.22.0 replace github.com/TBD54566975/ftl => ../../.. diff --git a/examples/kotlin/ftl-module-ad/pom.xml b/examples/kotlin/ftl-module-ad/pom.xml deleted file mode 100644 index bd2f97be8..000000000 --- a/examples/kotlin/ftl-module-ad/pom.xml +++ /dev/null @@ -1,197 +0,0 @@ - - - 4.0.0 - xyz.block - ad-kotlin - 1.0-SNAPSHOT - - - 1.0-SNAPSHOT - 1.8 - 1.9.0 - true - ${java.version} - ${java.version} - - - - - org.jetbrains.kotlin - kotlin-stdlib - ${kotlin.version} - - - ${project.groupId} - ftl-runtime - ${ftl.version} - - - ${project.groupId} - ftl-generator - ${ftl.version} - - - - - - - kotlin-maven-plugin - org.jetbrains.kotlin - ${kotlin.version} - - - compile - - compile - - - - ${project.basedir}/src/main/kotlin - - - - - test-compile - - test-compile - - - - ${project.basedir}/src/test/kotlin - - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - 3.2.0 - - - initialize - - copy - - - - - xyz.block - ftl-generator - ${ftl.version} - ftl-generator.jar - - - xyz.block - ftl-runtime - ${ftl.version} - ftl-runtime.jar - - - - - - copy-dependencies - compile - - copy-dependencies - - - ${project.build.directory}/dependency - runtime - - - - build-classpath - compile - - build-classpath - - - ${project.build.directory}/classpath.txt - generated.classpath - ${project.build.directory}/dependency - - - - - - - org.codehaus.mojo - exec-maven-plugin - 3.0.0 - - - initialize - - exec - - - java - - -jar - target/dependency/ftl-generator.jar - --endpoint=http://127.0.0.1:8892 - --dest=${project.build.directory} - --module=ad - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - 3.2.0 - - - generate-sources - - add-source - - - - ${project.build.directory}/generated-sources/ftl - - - - - - - com.github.ozsie - detekt-maven-plugin - 1.23.3.1 - - true - ${generated.classpath} - ${java.version} - ${project.build.directory}/detekt.yml - - - ${project.build.directory}/dependency/ftl-runtime-${ftl.version}.jar - - - ${project.basedir}/src/main/kotlin,${project.build.directory}/generated-sources - - - - compile - - check-with-type-resolution - - - - - - xyz.block - ftl-runtime - ${ftl.version} - - - - - - \ No newline at end of file diff --git a/examples/kotlin/ftl-module-ad/src/main/kotlin/ftl/ad/Ad.kt b/examples/kotlin/ftl-module-ad/src/main/kotlin/ftl/ad/Ad.kt deleted file mode 100644 index 1ce71cc9a..000000000 --- a/examples/kotlin/ftl-module-ad/src/main/kotlin/ftl/ad/Ad.kt +++ /dev/null @@ -1,59 +0,0 @@ -package ftl.ad - -import com.google.gson.Gson -import com.google.gson.reflect.TypeToken -import ftl.builtin.HttpRequest -import ftl.builtin.HttpResponse -import xyz.block.ftl.Context -import xyz.block.ftl.HttpIngress -import xyz.block.ftl.Method -import xyz.block.ftl.Verb -import java.util.* - -data class Ad(val redirectUrl: String, val text: String) -data class AdRequest(val contextKeys: List? = null) -data class AdResponse(val ads: List) - -private val database: Map = loadDatabase() - -@Verb -@HttpIngress(Method.GET, "/get") -fun get(context: Context, req: HttpRequest): HttpResponse { - val ads: List = when { - req.body.contextKeys != null -> contextualAds(req.body.contextKeys) - else -> randomAds() - } - - return HttpResponse(status = 200, headers = emptyMap(), body = AdResponse(ads = ads)) -} - -private fun contextualAds(contextKeys: List): List { - return contextKeys.map { database[it] ?: throw Exception("no ad registered for this context key") } -} - -private fun randomAds(): List { - val ads = mutableListOf() - val random = Random() - repeat(MAX_ADS_TO_SERVE) { - ads.add(database.entries.elementAt(random.nextInt(database.size)).value) - } - return ads -} - -private const val MAX_ADS_TO_SERVE = 2 -private val DATABASE = mapOf( - "hair" to Ad("/product/2ZYFJ3GM2N", "Hairdryer for sale. 50% off."), - "clothing" to Ad("/product/66VCHSJNUP", "Tank top for sale. 20% off."), - "accessories" to Ad("/product/1YMWWN1N4O", "Watch for sale. Buy one, get second kit for free"), - "footwear" to Ad("/product/L9ECAV7KIM", "Loafers for sale. Buy one, get second one for free"), - "decor" to Ad("/product/0PUK6V6EV0", "Candle holder for sale. 30% off."), - "kitchen" to Ad("/product/9SIQT8TOJO", "Bamboo glass jar for sale. 10% off.") -) - -private fun loadDatabase(): Map { - return DATABASE -} - -inline fun Gson.fromJson(json: String) = fromJson(json, object : TypeToken() {}.type) - - diff --git a/examples/kotlin/ftl-module-api/ftl.toml b/examples/kotlin/ftl-module-api/ftl.toml deleted file mode 100644 index c2a55f71c..000000000 --- a/examples/kotlin/ftl-module-api/ftl.toml +++ /dev/null @@ -1,2 +0,0 @@ -module = "api" -language = "kotlin" diff --git a/examples/kotlin/ftl-module-api/src/main/kotlin/ftl/api/Api.kt b/examples/kotlin/ftl-module-api/src/main/kotlin/ftl/api/Api.kt deleted file mode 100644 index 753d831f1..000000000 --- a/examples/kotlin/ftl-module-api/src/main/kotlin/ftl/api/Api.kt +++ /dev/null @@ -1,99 +0,0 @@ -package ftl.api - -import com.google.gson.Gson -import com.google.gson.GsonBuilder -import com.google.gson.JsonDeserializer -import com.google.gson.JsonPrimitive -import com.google.gson.JsonSerializer -import ftl.builtin.Empty -import ftl.builtin.HttpRequest -import ftl.builtin.HttpResponse -import xyz.block.ftl.* -import java.util.* -import java.util.concurrent.ConcurrentHashMap -import java.util.concurrent.atomic.AtomicInteger - -data class Todo( - val id: Int, - val title: String, - val completed: Boolean = false, -) - -data class GetStatusResponse( - val status: String, -) - -data class GetTodoRequest( - val id: Int, -) - -data class GetTodoResponse( - val todo: Todo?, -) - -data class CreateTodoRequest( - val title: String, -) - -data class CreateTodoResponse( - val id: Int, -) - -fun makeGson(): Gson = GsonBuilder() - .registerTypeAdapter(ByteArray::class.java, JsonSerializer { src, _, _ -> - JsonPrimitive(Base64.getEncoder().encodeToString(src)) - }) - .registerTypeAdapter(ByteArray::class.java, JsonDeserializer { json, _, _ -> - Base64.getDecoder().decode(json.asString) - }) - .create() - -// These are global because Api is stateless. -private val todos = ConcurrentHashMap() -private val idCounter = AtomicInteger() -private val gson = makeGson() - -private val headers = mapOf("Content-Type" to arrayListOf("application/json")) - -@Verb -@HttpIngress(Method.GET, "/api/status") -fun status(context: Context, req: HttpRequest): HttpResponse { - return HttpResponse(status = 200, headers = mapOf(), body = GetStatusResponse("OK")) -} - -@Verb -@HttpIngress(Method.GET, "/api/todos/{id}") -fun getTodo(context: Context, req: HttpRequest): HttpResponse { - val todoId = req.pathParameters["id"]?.toIntOrNull() - val todo = todos[todoId] - - return if (todo != null) { - HttpResponse( - status = 200, - headers = mapOf(), - body = GetTodoResponse(todo) - ) - } else { - HttpResponse(status = 404, headers = mapOf(), error = "Not found") - } -} - -@Verb -@HttpIngress(Method.POST, "/api/todos") -fun addTodo(context: Context, req: HttpRequest): HttpResponse { - val todoReq = req.body - val id = idCounter.incrementAndGet() - todos.put( - id, Todo( - id = id, - title = todoReq.title, - ) - ) - - return HttpResponse( - status = 201, - headers = headers, - body = CreateTodoResponse(id), - ) -} - diff --git a/examples/kotlin/ftl-module-ad/ftl.toml b/examples/kotlin/ftl-module-time/ftl.toml similarity index 55% rename from examples/kotlin/ftl-module-ad/ftl.toml rename to examples/kotlin/ftl-module-time/ftl.toml index 1438ed1b2..48033f28f 100644 --- a/examples/kotlin/ftl-module-ad/ftl.toml +++ b/examples/kotlin/ftl-module-time/ftl.toml @@ -1,2 +1,2 @@ -module = "ad" +module = "time" language = "kotlin" diff --git a/examples/kotlin/ftl-module-api/pom.xml b/examples/kotlin/ftl-module-time/pom.xml similarity index 94% rename from examples/kotlin/ftl-module-api/pom.xml rename to examples/kotlin/ftl-module-time/pom.xml index 4112240b9..612c71a6e 100644 --- a/examples/kotlin/ftl-module-api/pom.xml +++ b/examples/kotlin/ftl-module-time/pom.xml @@ -4,7 +4,7 @@ 4.0.0 ftl - ftl-module-api + ftl-module-time 1.0-SNAPSHOT ftl @@ -13,7 +13,7 @@ - api + time diff --git a/examples/kotlin/ftl-module-time/src/main/kotlin/ftl/time/Time.kt b/examples/kotlin/ftl-module-time/src/main/kotlin/ftl/time/Time.kt new file mode 100644 index 000000000..1d0d10944 --- /dev/null +++ b/examples/kotlin/ftl-module-time/src/main/kotlin/ftl/time/Time.kt @@ -0,0 +1,14 @@ +package ftl.time + +import ftl.builtin.Empty +import xyz.block.ftl.Context +import xyz.block.ftl.Verb +import java.time.OffsetDateTime + +// Make time an OffsetDateTime once schema extraction is fixed +data class TimeResponse(val time: String) + +@Verb +fun time(context: Context, req: Empty): TimeResponse { + return TimeResponse(time = OffsetDateTime.now().toString()) +} diff --git a/examples/kotlin/pom.xml b/examples/kotlin/pom.xml index 4a71f73a5..4882a58a3 100644 --- a/examples/kotlin/pom.xml +++ b/examples/kotlin/pom.xml @@ -10,7 +10,7 @@ ftl-module-echo - ftl-module-api + ftl-module-time diff --git a/examples/online-boutique/README.md b/examples/online-boutique/README.md deleted file mode 100644 index 6c7d52580..000000000 --- a/examples/online-boutique/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Online Boutique MicroServices Demo - -Based on the [GCP original](https://github.com/GoogleCloudPlatform/microservices-demo). diff --git a/examples/online-boutique/common/database.go b/examples/online-boutique/common/database.go deleted file mode 100644 index 02a733ff3..000000000 --- a/examples/online-boutique/common/database.go +++ /dev/null @@ -1,13 +0,0 @@ -package common - -import "encoding/json" - -// LoadDatabase loads a "database" from JSON. -func LoadDatabase[T any](data []byte) T { - var out T - err := json.Unmarshal(data, &out) - if err != nil { - panic(err) - } - return out -} diff --git a/examples/online-boutique/common/money/money.go b/examples/online-boutique/common/money/money.go deleted file mode 100644 index 50592b837..000000000 --- a/examples/online-boutique/common/money/money.go +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package money - -import ( - "errors" - - "ftl/currency" -) - -const ( - nanosMin = -999999999 - nanosMax = +999999999 - nanosMod = 1000000000 -) - -var ( - ErrInvalidValue = errors.New("one of the specified money values is invalid") - ErrMismatchingCurrency = errors.New("mismatching currency codes") -) - -// IsValid checks if specified value has a valid units/nanos signs and ranges. -func IsValid(m currency.Money) bool { - return signMatches(m) && validNanos(m.Nanos) -} - -func signMatches(m currency.Money) bool { - return m.Nanos == 0 || m.Units == 0 || (m.Nanos < 0) == (m.Units < 0) -} - -func validNanos(nanos int) bool { return nanosMin <= nanos && nanos <= nanosMax } - -// IsZero returns true if the specified money value is equal to zero. -func IsZero(m currency.Money) bool { return m.Units == 0 && m.Nanos == 0 } - -// IsPositive returns true if the specified money value is valid and is -// positive. -func IsPositive(m currency.Money) bool { - return IsValid(m) && m.Units > 0 || (m.Units == 0 && m.Nanos > 0) -} - -// IsNegative returns true if the specified money value is valid and is -// negative. -func IsNegative(m currency.Money) bool { - return IsValid(m) && m.Units < 0 || (m.Units == 0 && m.Nanos < 0) -} - -// AreSameCurrency returns true if values l and r have a currency code and -// they are the same values. -func AreSameCurrency(l, r currency.Money) bool { - return l.CurrencyCode == r.CurrencyCode && l.CurrencyCode != "" -} - -// AreEquals returns true if values l and r are the equal, including the -// -// This does not check validity of the provided values. -func AreEquals(l, r currency.Money) bool { - return l.CurrencyCode == r.CurrencyCode && - l.Units == r.Units && l.Nanos == r.Nanos -} - -// Negate returns the same amount with the sign negated. -func Negate(m currency.Money) currency.Money { - return currency.Money{ - Units: -m.Units, - Nanos: -m.Nanos, - CurrencyCode: m.CurrencyCode} -} - -// Must panics if the given error is not nil. This can be used with other -// functions like: "m := Must(Sum(a,b))". -func Must(v currency.Money, err error) currency.Money { - if err != nil { - panic(err) - } - return v -} - -// Sum adds two values. Returns an error if one of the values are invalid or -// currency codes are not matching (unless currency code is unspecified for -// both). -func Sum(l, r currency.Money) (currency.Money, error) { - if !IsValid(l) || !IsValid(r) { - return currency.Money{}, ErrInvalidValue - } else if l.CurrencyCode != r.CurrencyCode { - return currency.Money{}, ErrMismatchingCurrency - } - units := l.Units + r.Units - nanos := l.Nanos + r.Nanos - - if (units == 0 && nanos == 0) || (units > 0 && nanos >= 0) || (units < 0 && nanos <= 0) { - // same sign - units += nanos / nanosMod - nanos = nanos % nanosMod - } else { - // different sign. nanos guaranteed to not to go over the limit - if units > 0 { - units-- - nanos += nanosMod - } else { - units++ - nanos -= nanosMod - } - } - - return currency.Money{ - Units: units, - Nanos: nanos, - CurrencyCode: l.CurrencyCode}, nil -} - -// MultiplySlow is a slow multiplication operation done through adding the value -// to itself n-1 times. -func MultiplySlow(m currency.Money, n uint32) currency.Money { - out := m - for n > 1 { - out = Must(Sum(out, m)) - n-- - } - return out -} diff --git a/examples/online-boutique/common/money/money_test.go b/examples/online-boutique/common/money/money_test.go deleted file mode 100644 index a9d2c1d9c..000000000 --- a/examples/online-boutique/common/money/money_test.go +++ /dev/null @@ -1,245 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package money - -import ( - "fmt" - "reflect" - "testing" -) - -func mmc(u int, n int, c string) Money { - return Money{Units: u, Nanos: n, CurrencyCode: c} -} -func mm(u int, n int) Money { return mmc(u, n, "") } - -func TestIsValid(t *testing.T) { - tests := []struct { - name string - in Money - want bool - }{ - {"valid -/-", mm(-981273891273, -999999999), true}, - {"invalid -/+", mm(-981273891273, +999999999), false}, - {"valid +/+", mm(981273891273, 999999999), true}, - {"invalid +/-", mm(981273891273, -999999999), false}, - {"invalid +/+overflow", mm(3, 1000000000), false}, - {"invalid +/-overflow", mm(3, -1000000000), false}, - {"invalid -/+overflow", mm(-3, 1000000000), false}, - {"invalid -/-overflow", mm(-3, -1000000000), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := IsValid(tt.in); got != tt.want { - t.Errorf("IsValid(%v) = %v, want %v", tt.in, got, tt.want) - } - }) - } -} - -func TestIsZero(t *testing.T) { - tests := []struct { - name string - in Money - want bool - }{ - {"zero", mm(0, 0), true}, - {"not-zero (-/+)", mm(-1, +1), false}, - {"not-zero (-/-)", mm(-1, -1), false}, - {"not-zero (+/+)", mm(+1, +1), false}, - {"not-zero (+/-)", mm(+1, -1), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := IsZero(tt.in); got != tt.want { - t.Errorf("IsZero(%v) = %v, want %v", tt.in, got, tt.want) - } - }) - } -} - -func TestIsPositive(t *testing.T) { - tests := []struct { - name string - in Money - want bool - }{ - {"zero", mm(0, 0), false}, - {"positive (+/+)", mm(+1, +1), true}, - {"invalid (-/+)", mm(-1, +1), false}, - {"negative (-/-)", mm(-1, -1), false}, - {"invalid (+/-)", mm(+1, -1), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := IsPositive(tt.in); got != tt.want { - t.Errorf("IsPositive(%v) = %v, want %v", tt.in, got, tt.want) - } - }) - } -} - -func TestIsNegative(t *testing.T) { - tests := []struct { - name string - in Money - want bool - }{ - {"zero", mm(0, 0), false}, - {"positive (+/+)", mm(+1, +1), false}, - {"invalid (-/+)", mm(-1, +1), false}, - {"negative (-/-)", mm(-1, -1), true}, - {"invalid (+/-)", mm(+1, -1), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := IsNegative(tt.in); got != tt.want { - t.Errorf("IsNegative(%v) = %v, want %v", tt.in, got, tt.want) - } - }) - } -} - -func TestAreSameCurrency(t *testing.T) { - type args struct { - l Money - r Money - } - tests := []struct { - name string - args args - want bool - }{ - {"both empty currency", args{mmc(1, 0, ""), mmc(2, 0, "")}, false}, - {"left empty currency", args{mmc(1, 0, ""), mmc(2, 0, "USD")}, false}, - {"right empty currency", args{mmc(1, 0, "USD"), mmc(2, 0, "")}, false}, - {"mismatching", args{mmc(1, 0, "USD"), mmc(2, 0, "CAD")}, false}, - {"matching", args{mmc(1, 0, "USD"), mmc(2, 0, "USD")}, true}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := AreSameCurrency(tt.args.l, tt.args.r); got != tt.want { - t.Errorf("AreSameCurrency([%v],[%v]) = %v, want %v", tt.args.l, tt.args.r, got, tt.want) - } - }) - } -} - -func TestAreEquals(t *testing.T) { - type args struct { - l Money - r Money - } - tests := []struct { - name string - args args - want bool - }{ - {"equals", args{mmc(1, 2, "USD"), mmc(1, 2, "USD")}, true}, - {"mismatching currency", args{mmc(1, 2, "USD"), mmc(1, 2, "CAD")}, false}, - {"mismatching units", args{mmc(10, 20, "USD"), mmc(1, 20, "USD")}, false}, - {"mismatching nanos", args{mmc(1, 2, "USD"), mmc(1, 20, "USD")}, false}, - {"negated", args{mmc(1, 2, "USD"), mmc(-1, -2, "USD")}, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := AreEquals(tt.args.l, tt.args.r); got != tt.want { - t.Errorf("AreEquals([%v],[%v]) = %v, want %v", tt.args.l, tt.args.r, got, tt.want) - } - }) - } -} - -func TestNegate(t *testing.T) { - tests := []struct { - name string - in Money - want Money - }{ - {"zero", mm(0, 0), mm(0, 0)}, - {"negative", mm(-1, -200), mm(1, 200)}, - {"positive", mm(1, 200), mm(-1, -200)}, - {"carries currency code", mmc(0, 0, "XXX"), mmc(0, 0, "XXX")}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := Negate(tt.in); !AreEquals(got, tt.want) { - t.Errorf("Negate([%v]) = %v, want %v", tt.in, got, tt.want) - } - }) - } -} - -func TestMust_pass(t *testing.T) { - v := Must(mm(2, 3), nil) - if !AreEquals(v, mm(2, 3)) { - t.Errorf("returned the wrong value: %v", v) - } -} - -func TestMust_panic(t *testing.T) { - defer func() { - if r := recover(); r != nil { - t.Logf("panic captured: %v", r) - } - }() - Must(mm(2, 3), fmt.Errorf("some error")) - t.Fatal("this should not have executed due to the panic above") -} - -func TestSum(t *testing.T) { - type args struct { - l Money - r Money - } - tests := []struct { - name string - args args - want Money - wantErr error - }{ - {"0+0=0", args{mm(0, 0), mm(0, 0)}, mm(0, 0), nil}, - {"Error: currency code on left", args{mmc(0, 0, "XXX"), mm(0, 0)}, mm(0, 0), ErrMismatchingCurrency}, - {"Error: currency code on right", args{mm(0, 0), mmc(0, 0, "YYY")}, mm(0, 0), ErrMismatchingCurrency}, - {"Error: currency code mismatch", args{mmc(0, 0, "AAA"), mmc(0, 0, "BBB")}, mm(0, 0), ErrMismatchingCurrency}, - {"Error: invalid +/-", args{mm(+1, -1), mm(0, 0)}, mm(0, 0), ErrInvalidValue}, - {"Error: invalid -/+", args{mm(0, 0), mm(-1, +2)}, mm(0, 0), ErrInvalidValue}, - {"Error: invalid nanos", args{mm(0, 1000000000), mm(1, 0)}, mm(0, 0), ErrInvalidValue}, - {"both positive (no carry)", args{mm(2, 200000000), mm(2, 200000000)}, mm(4, 400000000), nil}, - {"both positive (nanos=max)", args{mm(2, 111111111), mm(2, 888888888)}, mm(4, 999999999), nil}, - {"both positive (carry)", args{mm(2, 200000000), mm(2, 900000000)}, mm(5, 100000000), nil}, - {"both negative (no carry)", args{mm(-2, -200000000), mm(-2, -200000000)}, mm(-4, -400000000), nil}, - {"both negative (carry)", args{mm(-2, -200000000), mm(-2, -900000000)}, mm(-5, -100000000), nil}, - {"mixed (larger positive, just decimals)", args{mm(11, 0), mm(-2, 0)}, mm(9, 0), nil}, - {"mixed (larger negative, just decimals)", args{mm(-11, 0), mm(2, 0)}, mm(-9, 0), nil}, - {"mixed (larger positive, no borrow)", args{mm(11, 100000000), mm(-2, -100000000)}, mm(9, 0), nil}, - {"mixed (larger positive, with borrow)", args{mm(11, 100000000), mm(-2, -9000000 /*.09*/)}, mm(9, 91000000 /*.091*/), nil}, - {"mixed (larger negative, no borrow)", args{mm(-11, -100000000), mm(2, 100000000)}, mm(-9, 0), nil}, - {"mixed (larger negative, with borrow)", args{mm(-11, -100000000), mm(2, 9000000 /*.09*/)}, mm(-9, -91000000 /*.091*/), nil}, - {"0+negative", args{mm(0, 0), mm(-2, -100000000)}, mm(-2, -100000000), nil}, - {"negative+0", args{mm(-2, -100000000), mm(0, 0)}, mm(-2, -100000000), nil}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - got, err := Sum(tt.args.l, tt.args.r) - if err != tt.wantErr { - t.Errorf("Sum([%v],[%v]): expected err=\"%v\" got=\"%v\"", tt.args.l, tt.args.r, tt.wantErr, err) - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Sum([%v],[%v]) = %v, want %v", tt.args.l, tt.args.r, got, tt.want) - } - }) - } -} diff --git a/examples/online-boutique/demo.proto b/examples/online-boutique/demo.proto deleted file mode 100644 index 969392863..000000000 --- a/examples/online-boutique/demo.proto +++ /dev/null @@ -1,260 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package hipstershop; - -// -----------------Cart service----------------- - -service CartService { - rpc AddItem(AddItemRequest) returns (Empty) {} - rpc GetCart(GetCartRequest) returns (Cart) {} - rpc EmptyCart(EmptyCartRequest) returns (Empty) {} -} - -message CartItem { - string product_id = 1; - int32 quantity = 2; -} - -message AddItemRequest { - string user_id = 1; - CartItem item = 2; -} - -message EmptyCartRequest { - string user_id = 1; -} - -message GetCartRequest { - string user_id = 1; -} - -message Cart { - string user_id = 1; - repeated CartItem items = 2; -} - -message Empty {} - -// ---------------Recommendation service---------- - -service RecommendationService { - rpc ListRecommendations(ListRecommendationsRequest) returns (ListRecommendationsResponse){} -} - -message ListRecommendationsRequest { - string user_id = 1; - repeated string product_ids = 2; -} - -message ListRecommendationsResponse { - repeated string product_ids = 1; -} - -// ---------------Product Catalog---------------- - -service ProductCatalogService { - rpc ListProducts(Empty) returns (ListProductsResponse) {} - rpc GetProduct(GetProductRequest) returns (Product) {} - rpc SearchProducts(SearchProductsRequest) returns (SearchProductsResponse) {} -} - -message Product { - string id = 1; - string name = 2; - string description = 3; - string picture = 4; - Money price_usd = 5; - - // Categories such as "clothing" or "kitchen" that can be used to look up - // other related products. - repeated string categories = 6; -} - -message ListProductsResponse { - repeated Product products = 1; -} - -message GetProductRequest { - string id = 1; -} - -message SearchProductsRequest { - string query = 1; -} - -message SearchProductsResponse { - repeated Product results = 1; -} - -// ---------------Shipping Service---------- - -service ShippingService { - rpc GetQuote(GetQuoteRequest) returns (GetQuoteResponse) {} - rpc ShipOrder(ShipOrderRequest) returns (ShipOrderResponse) {} -} - -message GetQuoteRequest { - Address address = 1; - repeated CartItem items = 2; -} - -message GetQuoteResponse { - Money cost_usd = 1; -} - -message ShipOrderRequest { - Address address = 1; - repeated CartItem items = 2; -} - -message ShipOrderResponse { - string tracking_id = 1; -} - -message Address { - string street_address = 1; - string city = 2; - string state = 3; - string country = 4; - int32 zip_code = 5; -} - -// -----------------Currency service----------------- - -service CurrencyService { - rpc GetSupportedCurrencies(Empty) returns (GetSupportedCurrenciesResponse) {} - rpc Convert(CurrencyConversionRequest) returns (Money) {} -} - -// Represents an amount of money with its currency type. -message Money { - // The 3-letter currency code defined in ISO 4217. - string currency_code = 1; - - // The whole units of the amount. - // For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar. - int64 units = 2; - - // Number of nano (10^-9) units of the amount. - // The value must be between -999,999,999 and +999,999,999 inclusive. - // If `units` is positive, `nanos` must be positive or zero. - // If `units` is zero, `nanos` can be positive, zero, or negative. - // If `units` is negative, `nanos` must be negative or zero. - // For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000. - int32 nanos = 3; -} - -message GetSupportedCurrenciesResponse { - // The 3-letter currency code defined in ISO 4217. - repeated string currency_codes = 1; -} - -message CurrencyConversionRequest { - Money from = 1; - - // The 3-letter currency code defined in ISO 4217. - string to_code = 2; -} - -// -------------Payment service----------------- - -service PaymentService { - rpc Charge(ChargeRequest) returns (ChargeResponse) {} -} - -message CreditCardInfo { - string credit_card_number = 1; - int32 credit_card_cvv = 2; - int32 credit_card_expiration_year = 3; - int32 credit_card_expiration_month = 4; -} - -message ChargeRequest { - Money amount = 1; - CreditCardInfo credit_card = 2; -} - -message ChargeResponse { - string transaction_id = 1; -} - -// -------------Email service----------------- - -service EmailService { - rpc SendOrderConfirmation(SendOrderConfirmationRequest) returns (Empty) {} -} - -message OrderItem { - CartItem item = 1; - Money cost = 2; -} - -message OrderResult { - string order_id = 1; - string shipping_tracking_id = 2; - Money shipping_cost = 3; - Address shipping_address = 4; - repeated OrderItem items = 5; -} - -message SendOrderConfirmationRequest { - string email = 1; - OrderResult order = 2; -} - - -// -------------Checkout service----------------- - -service CheckoutService { - rpc PlaceOrder(PlaceOrderRequest) returns (PlaceOrderResponse) {} -} - -message PlaceOrderRequest { - string user_id = 1; - string user_currency = 2; - - Address address = 3; - string email = 5; - CreditCardInfo credit_card = 6; -} - -message PlaceOrderResponse { - OrderResult order = 1; -} - -// ------------Ad service------------------ - -service AdService { - rpc GetAds(AdRequest) returns (AdResponse) {} -} - -message AdRequest { - // List of important key words from the current page describing the context. - repeated string context_keys = 1; -} - -message AdResponse { - repeated Ad ads = 1; -} - -message Ad { - // url to redirect to when an ad is clicked. - string redirect_url = 1; - - // short advertisement text to display. - string text = 2; -} diff --git a/examples/online-boutique/go.mod b/examples/online-boutique/go.mod deleted file mode 100644 index 135a059d4..000000000 --- a/examples/online-boutique/go.mod +++ /dev/null @@ -1,5 +0,0 @@ -module github.com/TBD54566975/ftl/examples/online-boutique - -go 1.21.6 - -replace github.com/TBD54566975/ftl => ../.. diff --git a/examples/online-boutique/go.sum b/examples/online-boutique/go.sum deleted file mode 100644 index e69de29bb..000000000 diff --git a/examples/online-boutique/services/ad/ad.go b/examples/online-boutique/services/ad/ad.go deleted file mode 100644 index 5cbbfd573..000000000 --- a/examples/online-boutique/services/ad/ad.go +++ /dev/null @@ -1,67 +0,0 @@ -//ftl:module ad -package ad - -import ( - "context" - _ "embed" - "math/rand" - - "ftl/builtin" - - "github.com/TBD54566975/ftl/examples/online-boutique/common" - "golang.org/x/exp/maps" -) - -const maxAdsToServe = 2 - -var ( - //go:embed database.json - databaseJSON []byte - database = common.LoadDatabase[map[string]Ad](databaseJSON) -) - -type AdRequest struct { - ContextKeys []string -} - -type Ad struct { - RedirectURL string - Text string -} - -type AdResponse struct { - Name string - Ads []Ad -} - -//ftl:verb -//ftl:ingress GET /ad -func Get(ctx context.Context, req builtin.HttpRequest[AdRequest]) (builtin.HttpResponse[AdResponse], error) { - var ads []Ad - if len(req.Body.ContextKeys) > 0 { - ads = contextualAds(req.Body.ContextKeys) - } else { - ads = randomAds() - } - - return builtin.HttpResponse[AdResponse]{ - Body: AdResponse{Name: "ad", Ads: ads}, - }, nil -} - -func contextualAds(contextKeys []string) (ads []Ad) { - for _, key := range contextKeys { - if ad, ok := database[key]; ok { - ads = append(ads, ad) - } - } - return ads -} - -func randomAds() (ads []Ad) { - allAds := maps.Values(database) - for i := 0; i < maxAdsToServe; i++ { - ads = append(ads, allAds[rand.Intn(len(allAds))]) - } - return ads -} diff --git a/examples/online-boutique/services/ad/database.json b/examples/online-boutique/services/ad/database.json deleted file mode 100644 index 577a5b9f9..000000000 --- a/examples/online-boutique/services/ad/database.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "hair": { - "RedirectURL": "/product/2ZYFJ3GM2N", - "Text": "Hairdryer for sale. 50% off." - }, - "clothing": { - "RedirectURL": "/product/66VCHSJNUP", - "Text": "Tank top for sale. 20% off." - }, - "accessories": { - "RedirectURL": "/product/1YMWWN1N4O", - "Text": "Watch for sale. Buy one, get second kit for free" - }, - "footwear": { - "RedirectURL": "/product/L9ECAV7KIM", - "Text": "Loafers for sale. Buy one, get second one for free" - }, - "decor": { - "RedirectURL": "/product/0PUK6V6EV0", - "Text": "Candle holder for sale. 30% off." - }, - "kitchen": { - "RedirectURL": "/product/9SIQT8TOJO", - "Text": "Bamboo glass jar for sale. 10% off." - } -} \ No newline at end of file diff --git a/examples/online-boutique/services/ad/ftl.toml b/examples/online-boutique/services/ad/ftl.toml deleted file mode 100644 index ad433ebe9..000000000 --- a/examples/online-boutique/services/ad/ftl.toml +++ /dev/null @@ -1,2 +0,0 @@ -module = "ad" -language = "go" diff --git a/examples/online-boutique/services/ad/go.mod b/examples/online-boutique/services/ad/go.mod deleted file mode 100644 index 06c60f68e..000000000 --- a/examples/online-boutique/services/ad/go.mod +++ /dev/null @@ -1,12 +0,0 @@ -module ftl/ad - -go 1.21.6 - -replace github.com/TBD54566975/ftl => ../../../.. - -replace github.com/TBD54566975/ftl/examples/online-boutique => ../.. - -require ( - github.com/TBD54566975/ftl/examples/online-boutique v0.0.0-00010101000000-000000000000 - golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3 -) diff --git a/examples/online-boutique/services/ad/go.sum b/examples/online-boutique/services/ad/go.sum deleted file mode 100644 index 3707af3cb..000000000 --- a/examples/online-boutique/services/ad/go.sum +++ /dev/null @@ -1,2 +0,0 @@ -golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3 h1:hNQpMuAJe5CtcUqCXaWga3FHu+kQvCqcsoVaQgSV60o= -golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= diff --git a/examples/online-boutique/services/cart/cart.go b/examples/online-boutique/services/cart/cart.go deleted file mode 100644 index 610a71200..000000000 --- a/examples/online-boutique/services/cart/cart.go +++ /dev/null @@ -1,62 +0,0 @@ -//ftl:module cart -package cart - -import ( - "context" - "ftl/builtin" -) - -var store = NewStore() - -type Item struct { - ProductID string `json:"productID"` - Quantity int `json:"quantity"` -} - -type AddItemRequest struct { - UserID string `json:"userID"` - Item Item `json:"item"` -} - -type AddItemResponse struct{} - -type Cart struct { - UserID string `json:"userID"` - Items []Item `json:"items"` -} - -//ftl:verb -//ftl:ingress POST /cart/add -func AddItem(ctx context.Context, req builtin.HttpRequest[AddItemRequest]) (builtin.HttpResponse[AddItemResponse], error) { - store.Add(req.Body.UserID, req.Body.Item) - return builtin.HttpResponse[AddItemResponse]{ - Body: AddItemResponse{}, - }, nil -} - -type GetCartRequest struct { - UserID string `json:"userID"` -} - -//ftl:verb -//ftl:ingress GET /cart -func GetCart(ctx context.Context, req builtin.HttpRequest[GetCartRequest]) (builtin.HttpResponse[Cart], error) { - return builtin.HttpResponse[Cart]{ - Body: Cart{Items: store.Get(req.Body.UserID), UserID: req.Body.UserID}, - }, nil -} - -type EmptyCartRequest struct { - UserID string `json:"userID"` -} - -type EmptyCartResponse struct{} - -//ftl:verb -//ftl:ingress POST /cart/empty -func EmptyCart(ctx context.Context, req builtin.HttpRequest[EmptyCartRequest]) (builtin.HttpResponse[EmptyCartResponse], error) { - store.Empty(req.Body.UserID) - return builtin.HttpResponse[EmptyCartResponse]{ - Body: EmptyCartResponse{}, - }, nil -} diff --git a/examples/online-boutique/services/cart/ftl.toml b/examples/online-boutique/services/cart/ftl.toml deleted file mode 100644 index 36d2a708c..000000000 --- a/examples/online-boutique/services/cart/ftl.toml +++ /dev/null @@ -1,2 +0,0 @@ -module = "cart" -language = "go" diff --git a/examples/online-boutique/services/cart/go.mod b/examples/online-boutique/services/cart/go.mod deleted file mode 100644 index 8eae49a3f..000000000 --- a/examples/online-boutique/services/cart/go.mod +++ /dev/null @@ -1,9 +0,0 @@ -module ftl/cart - -go 1.21.6 - -replace github.com/TBD54566975/ftl => ../../../.. - -replace github.com/TBD54566975/ftl/examples/online-boutique => ../.. - -require github.com/hashicorp/golang-lru/v2 v2.0.7 diff --git a/examples/online-boutique/services/cart/go.sum b/examples/online-boutique/services/cart/go.sum deleted file mode 100644 index a33c54a15..000000000 --- a/examples/online-boutique/services/cart/go.sum +++ /dev/null @@ -1,2 +0,0 @@ -github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= -github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= diff --git a/examples/online-boutique/services/cart/store.go b/examples/online-boutique/services/cart/store.go deleted file mode 100644 index 702807a05..000000000 --- a/examples/online-boutique/services/cart/store.go +++ /dev/null @@ -1,63 +0,0 @@ -package cart - -import ( - "sync" - - lru "github.com/hashicorp/golang-lru/v2" -) - -type Store struct { - lock sync.Mutex - carts *lru.Cache[string, []Item] -} - -func NewStore() *Store { - cache, err := lru.New[string, []Item](100) - if err != nil { - panic(err) - } - return &Store{carts: cache} -} - -func (s *Store) Add(userID string, newItem Item) { - s.lock.Lock() - defer s.lock.Unlock() - items, ok := s.carts.Get(userID) - if !ok { - s.carts.Add(userID, []Item{newItem}) - return - } - - found := false - for i, existingItem := range items { - if existingItem.ProductID == newItem.ProductID { - items[i].Quantity += newItem.Quantity - found = true - break - } - } - - if !found { - items = append(items, newItem) - } - - s.carts.Add(userID, items) -} - -func (s *Store) Get(userID string) []Item { - s.lock.Lock() - defer s.lock.Unlock() - items, ok := s.carts.Get(userID) - if !ok { - return []Item{} - } - out := make([]Item, len(items)) - copy(out, items) - return out -} - -func (s *Store) Empty(userID string) { - s.lock.Lock() - defer s.lock.Unlock() - s.carts.Remove(userID) -} diff --git a/examples/online-boutique/services/checkout/checkout.go b/examples/online-boutique/services/checkout/checkout.go deleted file mode 100644 index 076720f31..000000000 --- a/examples/online-boutique/services/checkout/checkout.go +++ /dev/null @@ -1,138 +0,0 @@ -//ftl:module checkout -package checkout - -import ( - "context" - "fmt" - - "github.com/google/uuid" - - "ftl/builtin" - "ftl/cart" - "ftl/currency" - "ftl/payment" - "ftl/productcatalog" - "ftl/shipping" - - "github.com/TBD54566975/ftl/backend/common/slices" - "github.com/TBD54566975/ftl/examples/online-boutique/common/money" - - ftl "github.com/TBD54566975/ftl/go-runtime/ftl" -) - -type PlaceOrderRequest struct { - UserID string - UserCurrency string - - Address shipping.Address - Email string - CreditCard payment.CreditCardInfo -} - -type OrderItem struct { - Item cart.Item - Cost currency.Money -} - -type Order struct { - ID string - ShippingTrackingID string - ShippingCost currency.Money - ShippingAddress shipping.Address - Items []OrderItem -} - -//ftl:verb -//ftl:ingress POST /checkout/{userID} -func PlaceOrder(ctx context.Context, req builtin.HttpRequest[PlaceOrderRequest]) (builtin.HttpResponse[Order], error) { - cartItems, err := ftl.Call(ctx, cart.GetCart, builtin.HttpRequest[cart.GetCartRequest]{Body: cart.GetCartRequest{UserID: req.Body.UserID}}) - if err != nil { - return builtin.HttpResponse[Order]{}, fmt.Errorf("failed to get cart: %w", err) - } - - orders := make([]OrderItem, len(cartItems.Body.Items)) - for i, item := range cartItems.Body.Items { - products, err := ftl.Call(ctx, productcatalog.Get, builtin.HttpRequest[productcatalog.GetRequest]{Body: productcatalog.GetRequest{Id: item.ProductID}}) - if err != nil { - return builtin.HttpResponse[Order]{}, fmt.Errorf("failed to get product #%q: %w", item.ProductID, err) - } - price, err := ftl.Call(ctx, currency.Convert, builtin.HttpRequest[currency.ConvertRequest]{ - Body: currency.ConvertRequest{ - From: products.Body.PriceUSD, - ToCode: req.Body.UserCurrency, - }, - }) - if err != nil { - return builtin.HttpResponse[Order]{}, fmt.Errorf("failed to convert price of %q to %s: %w", item.ProductID, req.Body.UserCurrency, err) - } - orders[i] = OrderItem{ - Item: item, - Cost: price.Body, - } - } - - shippingUSD, err := ftl.Call(ctx, shipping.GetQuote, builtin.HttpRequest[shipping.ShippingRequest]{ - Body: shipping.ShippingRequest{ - Address: req.Body.Address, - Items: slices.Map(orders, func(i OrderItem) cart.Item { return i.Item }), - }, - }) - if err != nil { - return builtin.HttpResponse[Order]{}, fmt.Errorf("failed to get shipping quote: %w", err) - } - shippingPrice, err := ftl.Call(ctx, currency.Convert, builtin.HttpRequest[currency.ConvertRequest]{ - Body: currency.ConvertRequest{ - From: shippingUSD.Body, - ToCode: req.Body.UserCurrency, - }, - }) - if err != nil { - return builtin.HttpResponse[Order]{}, fmt.Errorf("failed to convert shipping cost to currency: %w", err) - } - - total := currency.Money{CurrencyCode: req.Body.UserCurrency} - total = money.Must(money.Sum(total, shippingPrice.Body)) - for _, it := range orders { - multPrice := money.MultiplySlow(it.Cost, uint32(it.Item.Quantity)) - total = money.Must(money.Sum(total, multPrice)) - } - txID, err := ftl.Call(ctx, payment.Charge, builtin.HttpRequest[payment.ChargeRequest]{ - Body: payment.ChargeRequest{ - Amount: total, - CreditCard: req.Body.CreditCard, - }, - }) - if err != nil { - return builtin.HttpResponse[Order]{}, fmt.Errorf("failed to charge card: %w", err) - } - fmt.Printf("Charged card, ID %s", txID.Body.TransactionID) - - shippingTrackingID, err := ftl.Call(ctx, shipping.ShipOrder, builtin.HttpRequest[shipping.ShippingRequest]{ - Body: shipping.ShippingRequest{ - Address: req.Body.Address, - Items: cartItems.Body.Items, - }, - }) - if err != nil { - return builtin.HttpResponse[Order]{}, fmt.Errorf("shipping error: %w", err) - } - fmt.Printf("Shipped order, tracking ID %s", shippingTrackingID.Body.Id) - - // Empty the cart, but don't worry about errors. - _, _ = ftl.Call(ctx, cart.EmptyCart, builtin.HttpRequest[cart.EmptyCartRequest]{Body: cart.EmptyCartRequest{UserID: req.Body.UserID}}) - - order := Order{ - ID: uuid.New().String(), - ShippingTrackingID: shippingTrackingID.Body.Id, - ShippingCost: shippingPrice.Body, - ShippingAddress: req.Body.Address, - Items: orders, - } - // if err := s.emailService.Get().SendOrderConfirmation(ctx, req.Email, order); err != nil { - // s.Logger(ctx).Error("failed to send order confirmation", "err", err, "email", req.Email) - // } else { - // s.Logger(ctx).Info("order confirmation email sent", "email", req.Email) - // } - - return builtin.HttpResponse[Order]{Body: order}, nil -} diff --git a/examples/online-boutique/services/checkout/ftl.toml b/examples/online-boutique/services/checkout/ftl.toml deleted file mode 100644 index 6096398f2..000000000 --- a/examples/online-boutique/services/checkout/ftl.toml +++ /dev/null @@ -1,2 +0,0 @@ -module = "checkout" -language = "go" diff --git a/examples/online-boutique/services/checkout/go.mod b/examples/online-boutique/services/checkout/go.mod deleted file mode 100644 index f4a49b3df..000000000 --- a/examples/online-boutique/services/checkout/go.mod +++ /dev/null @@ -1,50 +0,0 @@ -module ftl/checkout - -go 1.22.0 - -replace github.com/TBD54566975/ftl => ../../../.. - -replace github.com/TBD54566975/ftl/examples/online-boutique => ../.. - -require ( - github.com/TBD54566975/ftl v0.0.0-00010101000000-000000000000 - github.com/TBD54566975/ftl/examples/online-boutique v0.0.0-00010101000000-000000000000 - github.com/google/uuid v1.6.0 -) - -require ( - connectrpc.com/connect v1.14.0 // indirect - connectrpc.com/grpcreflect v1.2.0 // indirect - connectrpc.com/otelconnect v0.7.0 // indirect - github.com/alecthomas/concurrency v0.0.2 // indirect - github.com/alecthomas/participle/v2 v2.1.1 // indirect - github.com/alecthomas/types v0.10.1 // indirect - github.com/alessio/shellescape v1.4.2 // indirect - github.com/danieljoos/wincred v1.2.0 // indirect - github.com/go-logr/logr v1.4.1 // indirect - github.com/go-logr/stdr v1.2.2 // indirect - github.com/godbus/dbus/v5 v5.1.0 // indirect - github.com/jackc/pgpassfile v1.0.0 // indirect - github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect - github.com/jackc/pgx/v5 v5.5.3 // indirect - github.com/jackc/puddle/v2 v2.2.1 // indirect - github.com/jpillora/backoff v1.0.0 // indirect - github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect - github.com/oklog/ulid/v2 v2.1.0 // indirect - github.com/swaggest/jsonschema-go v0.3.64 // indirect - github.com/swaggest/refl v1.3.0 // indirect - github.com/zalando/go-keyring v0.2.3 // indirect - go.opentelemetry.io/otel v1.23.1 // indirect - go.opentelemetry.io/otel/metric v1.23.1 // indirect - go.opentelemetry.io/otel/trace v1.23.1 // indirect - golang.design/x/reflect v0.0.0-20220504060917-02c43be63f3b // indirect - golang.org/x/crypto v0.19.0 // indirect - golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 // indirect - golang.org/x/mod v0.15.0 // indirect - golang.org/x/net v0.21.0 // indirect - golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/text v0.14.0 // indirect - google.golang.org/protobuf v1.32.0 // indirect -) diff --git a/examples/online-boutique/services/checkout/go.sum b/examples/online-boutique/services/checkout/go.sum deleted file mode 100644 index 1650df7dd..000000000 --- a/examples/online-boutique/services/checkout/go.sum +++ /dev/null @@ -1,143 +0,0 @@ -connectrpc.com/connect v1.14.0 h1:PDS+J7uoz5Oui2VEOMcfz6Qft7opQM9hPiKvtGC01pA= -connectrpc.com/connect v1.14.0/go.mod h1:uoAq5bmhhn43TwhaKdGKN/bZcGtzPW1v+ngDTn5u+8s= -connectrpc.com/grpcreflect v1.2.0 h1:Q6og1S7HinmtbEuBvARLNwYmTbhEGRpHDhqrPNlmK+U= -connectrpc.com/grpcreflect v1.2.0/go.mod h1:nwSOKmE8nU5u/CidgHtPYk1PFI3U9ignz7iDMxOYkSY= -connectrpc.com/otelconnect v0.7.0 h1:ZH55ZZtcJOTKWWLy3qmL4Pam4RzRWBJFOqTPyAqCXkY= -connectrpc.com/otelconnect v0.7.0/go.mod h1:Bt2ivBymHZHqxvo4HkJ0EwHuUzQN6k2l0oH+mp/8nwc= -github.com/alecthomas/assert/v2 v2.5.0 h1:OJKYg53BQx06/bMRBSPDCO49CbCDNiUQXwdoNrt6x5w= -github.com/alecthomas/assert/v2 v2.5.0/go.mod h1:fw5suVxB+wfYJ3291t0hRTqtGzFYdSwstnRQdaQx2DM= -github.com/alecthomas/concurrency v0.0.2 h1:Q3kGPtLbleMbH9lHX5OBFvJygfyFw29bXZKBg+IEVuo= -github.com/alecthomas/concurrency v0.0.2/go.mod h1:GmuQb/iHX7mbNtPlC/WDzEFxDMB0HYFer2Qda9QTs7w= -github.com/alecthomas/participle/v2 v2.1.1 h1:hrjKESvSqGHzRb4yW1ciisFJ4p3MGYih6icjJvbsmV8= -github.com/alecthomas/participle/v2 v2.1.1/go.mod h1:Y1+hAs8DHPmc3YUFzqllV+eSQ9ljPTk0ZkPMtEdAx2c= -github.com/alecthomas/repr v0.3.0 h1:NeYzUPfjjlqHY4KtzgKJiWd6sVq2eNUPTi34PiFGjY8= -github.com/alecthomas/repr v0.3.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= -github.com/alecthomas/types v0.10.1 h1:PuBMoHpFL2jaW3VgPDRhCk1oKoBCzfbsL5sAxEc3U3A= -github.com/alecthomas/types v0.10.1/go.mod h1:fIOGnLeeUJXe1AAVofQmMaEMWLxY9bK4QxTLGIo30PA= -github.com/alessio/shellescape v1.4.2 h1:MHPfaU+ddJ0/bYWpgIeUnQUqKrlJ1S7BfEYPM4uEoM0= -github.com/alessio/shellescape v1.4.2/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30= -github.com/bool64/dev v0.2.31 h1:OS57EqYaYe2M/2bw9uhDCIFiZZwywKFS/4qMLN6JUmQ= -github.com/bool64/dev v0.2.31/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8ACg= -github.com/bool64/shared v0.1.5 h1:fp3eUhBsrSjNCQPcSdQqZxxh9bBwrYiZ+zOKFkM0/2E= -github.com/bool64/shared v0.1.5/go.mod h1:081yz68YC9jeFB3+Bbmno2RFWvGKv1lPKkMP6MHJlPs= -github.com/danieljoos/wincred v1.2.0 h1:ozqKHaLK0W/ii4KVbbvluM91W2H3Sh0BncbUNPS7jLE= -github.com/danieljoos/wincred v1.2.0/go.mod h1:FzQLLMKBFdvu+osBrnFODiv32YGwCfx0SkRa/eYHgec= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= -github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= -github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= -github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= -github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= -github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= -github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc= -github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE= -github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= -github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= -github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk= -github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= -github.com/jackc/pgx/v5 v5.5.3 h1:Ces6/M3wbDXYpM8JyyPD57ivTtJACFZJd885pdIaV2s= -github.com/jackc/pgx/v5 v5.5.3/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A= -github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk= -github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= -github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA= -github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= -github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= -github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/oklog/ulid/v2 v2.1.0 h1:+9lhoxAP56we25tyYETBBY1YLA2SaoLvUFgrP2miPJU= -github.com/oklog/ulid/v2 v2.1.0/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ= -github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= -github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= -github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 h1:lZUw3E0/J3roVtGQ+SCrUrg3ON6NgVqpn3+iol9aGu4= -github.com/santhosh-tekuri/jsonschema/v5 v5.3.1/go.mod h1:uToXkOrWAZ6/Oc07xWQrPOhJotwFIyu2bBVN41fcDUY= -github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= -github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/swaggest/assertjson v1.9.0 h1:dKu0BfJkIxv/xe//mkCrK5yZbs79jL7OVf9Ija7o2xQ= -github.com/swaggest/assertjson v1.9.0/go.mod h1:b+ZKX2VRiUjxfUIal0HDN85W0nHPAYUbYH5WkkSsFsU= -github.com/swaggest/jsonschema-go v0.3.64 h1:HyB41fkA4XP0BZkqWfGap5i2JtRHQGXG/21dGDPbyLM= -github.com/swaggest/jsonschema-go v0.3.64/go.mod h1:DYuKqdpms/edvywsX6p1zHXCZkdwB28wRaBdFCe3Duw= -github.com/swaggest/refl v1.3.0 h1:PEUWIku+ZznYfsoyheF97ypSduvMApYyGkYF3nabS0I= -github.com/swaggest/refl v1.3.0/go.mod h1:3Ujvbmh1pfSbDYjC6JGG7nMgPvpG0ehQL4iNonnLNbg= -github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCOA= -github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= -github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3IfnEUduWvb9is428/nNb5L3U01M= -github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= -github.com/zalando/go-keyring v0.2.3 h1:v9CUu9phlABObO4LPWycf+zwMG7nlbb3t/B5wa97yms= -github.com/zalando/go-keyring v0.2.3/go.mod h1:HL4k+OXQfJUWaMnqyuSOc0drfGPX2b51Du6K+MRgZMk= -go.opentelemetry.io/otel v1.23.1 h1:Za4UzOqJYS+MUczKI320AtqZHZb7EqxO00jAHE0jmQY= -go.opentelemetry.io/otel v1.23.1/go.mod h1:Td0134eafDLcTS4y+zQ26GE8u3dEuRBiBCTUIRHaikA= -go.opentelemetry.io/otel/metric v1.23.1 h1:PQJmqJ9u2QaJLBOELl1cxIdPcpbwzbkjfEyelTl2rlo= -go.opentelemetry.io/otel/metric v1.23.1/go.mod h1:mpG2QPlAfnK8yNhNJAxDZruU9Y1/HubbC+KyH8FaCWI= -go.opentelemetry.io/otel/sdk v1.23.1 h1:O7JmZw0h76if63LQdsBMKQDWNb5oEcOThG9IrxscV+E= -go.opentelemetry.io/otel/sdk v1.23.1/go.mod h1:LzdEVR5am1uKOOwfBWFef2DCi1nu3SA8XQxx2IerWFk= -go.opentelemetry.io/otel/sdk/metric v1.23.1 h1:T9/8WsYg+ZqIpMWwdISVVrlGb/N0Jr1OHjR/alpKwzg= -go.opentelemetry.io/otel/sdk/metric v1.23.1/go.mod h1:8WX6WnNtHCgUruJ4TJ+UssQjMtpxkpX0zveQC8JG/E0= -go.opentelemetry.io/otel/trace v1.23.1 h1:4LrmmEd8AU2rFvU1zegmvqW7+kWarxtNOPyeL6HmYY8= -go.opentelemetry.io/otel/trace v1.23.1/go.mod h1:4IpnpJFwr1mo/6HL8XIPJaE9y0+u1KcVmuW7dwFSVrI= -golang.design/x/reflect v0.0.0-20220504060917-02c43be63f3b h1:lkOPTy76R9NZ6FeDQWkDj3NsLtD8Csc9AAFYEl3kiME= -golang.design/x/reflect v0.0.0-20220504060917-02c43be63f3b/go.mod h1:QXG482h3unP32W/YwIPOc+09bvY447B7T+iLjC/JPcA= -golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= -golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= -golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 h1:/RIbNt/Zr7rVhIkQhooTxCxFcdWLGIKnZA4IXNFSrvo= -golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= -golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= -golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= -golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= -google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= -google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -lukechampine.com/uint128 v1.2.0 h1:mBi/5l91vocEN8otkC5bDLhi2KdCticRiwbdB0O+rjI= -lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= -modernc.org/cc/v3 v3.40.0 h1:P3g79IUS/93SYhtoeaHW+kRCIrYaxJ27MFPv+7kaTOw= -modernc.org/cc/v3 v3.40.0/go.mod h1:/bTg4dnWkSXowUO6ssQKnOV0yMVxDYNIsIrzqTFDGH0= -modernc.org/ccgo/v3 v3.16.13 h1:Mkgdzl46i5F/CNR/Kj80Ri59hC8TKAhZrYSaqvkwzUw= -modernc.org/ccgo/v3 v3.16.13/go.mod h1:2Quk+5YgpImhPjv2Qsob1DnZ/4som1lJTodubIcoUkY= -modernc.org/libc v1.29.0 h1:tTFRFq69YKCF2QyGNuRUQxKBm1uZZLubf6Cjh/pVHXs= -modernc.org/libc v1.29.0/go.mod h1:DaG/4Q3LRRdqpiLyP0C2m1B8ZMGkQ+cCgOIjEtQlYhQ= -modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4= -modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo= -modernc.org/memory v1.7.2 h1:Klh90S215mmH8c9gO98QxQFsY+W451E8AnzjoE2ee1E= -modernc.org/memory v1.7.2/go.mod h1:NO4NVCQy0N7ln+T9ngWqOQfi7ley4vpwvARR+Hjw95E= -modernc.org/opt v0.1.3 h1:3XOZf2yznlhC+ibLltsDGzABUGVx8J6pnFMS3E4dcq4= -modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= -modernc.org/sqlite v1.28.0 h1:Zx+LyDDmXczNnEQdvPuEfcFVA2ZPyaD7UCZDjef3BHQ= -modernc.org/sqlite v1.28.0/go.mod h1:Qxpazz0zH8Z1xCFyi5GSL3FzbtZ3fvbjmywNogldEW0= -modernc.org/strutil v1.1.3 h1:fNMm+oJklMGYfU9Ylcywl0CO5O6nTfaowNsh2wpPjzY= -modernc.org/strutil v1.1.3/go.mod h1:MEHNA7PdEnEwLvspRMtWTNnp2nnyvMfkimT1NKNAGbw= -modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y= -modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= diff --git a/examples/online-boutique/services/currency/currency.go b/examples/online-boutique/services/currency/currency.go deleted file mode 100644 index af282020c..000000000 --- a/examples/online-boutique/services/currency/currency.go +++ /dev/null @@ -1,90 +0,0 @@ -//ftl:module currency -package currency - -import ( - "context" - _ "embed" - "fmt" - "math" - - "ftl/builtin" - - "golang.org/x/exp/maps" - - "github.com/TBD54566975/ftl/examples/online-boutique/common" -) - -var ( - //go:embed database.json - databaseJSON []byte - database = common.LoadDatabase[map[string]float64](databaseJSON) -) - -// Money represents an amount of money along with the currency type. -type Money struct { - // The 3-letter currency code defined in ISO 4217. - CurrencyCode string `json:"currencyCode"` - - // The whole units of the amount. - // For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar. - Units int `json:"units"` - - // Number of nano (10^-9) units of the amount. - // The value must be between -999,999,999 and +999,999,999 inclusive. - // If `units` is positive, `nanos` must be positive or zero. - // If `units` is zero, `nanos` can be positive, zero, or negative. - // If `units` is negative, `nanos` must be negative or zero. - // For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000. - Nanos int `json:"nanos"` -} - -type GetSupportedCurrenciesRequest struct { -} - -type GetSupportedCurrenciesResponse struct { - CurrencyCodes []string -} - -//ftl:verb -//ftl:ingress GET /currency/supported -func GetSupportedCurrencies(ctx context.Context, req builtin.HttpRequest[GetSupportedCurrenciesRequest]) (builtin.HttpResponse[GetSupportedCurrenciesResponse], error) { - return builtin.HttpResponse[GetSupportedCurrenciesResponse]{ - Body: GetSupportedCurrenciesResponse{CurrencyCodes: maps.Keys(database)}, - }, nil -} - -type ConvertRequest struct { - From Money - ToCode string -} - -//ftl:verb -//ftl:ingress POST /currency/convert -func Convert(ctx context.Context, req builtin.HttpRequest[ConvertRequest]) (builtin.HttpResponse[Money], error) { - from := req.Body.From - fromRate, ok := database[from.CurrencyCode] - if !ok { - return builtin.HttpResponse[Money]{}, fmt.Errorf("unknown origin currency %q", req.Body.From.CurrencyCode) - } - toRate, ok := database[req.Body.ToCode] - if !ok { - return builtin.HttpResponse[Money]{}, fmt.Errorf("unknown destination currency %q", req.Body.ToCode) - } - euros := carry(float64(from.Units)/fromRate, float64(from.Nanos)/fromRate) - to := carry(float64(euros.Units)*toRate, float64(euros.Nanos)*toRate) - to.CurrencyCode = req.Body.ToCode - - return builtin.HttpResponse[Money]{Body: to}, nil -} - -// carry is a helper function that handles decimal/fractional carrying. -func carry(units float64, nanos float64) Money { - const fractionSize = 1000000000 // 1B - nanos += math.Mod(units, 1.0) * fractionSize - units = math.Floor(units) + math.Floor(nanos/fractionSize) - nanos = math.Mod(nanos, fractionSize) - return Money{ - Units: int(units), - Nanos: int(nanos), - } -} diff --git a/examples/online-boutique/services/currency/database.json b/examples/online-boutique/services/currency/database.json deleted file mode 100644 index e2286671e..000000000 --- a/examples/online-boutique/services/currency/database.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "EUR": 1.0, - "USD": 1.1305, - "JPY": 126.40, - "BGN": 1.9558, - "CZK": 25.592, - "DKK": 7.4609, - "GBP": 0.85970, - "HUF": 315.51, - "PLN": 4.2996, - "RON": 4.7463, - "SEK": 10.5375, - "CHF": 1.1360, - "ISK": 136.80, - "NOK": 9.8040, - "HRK": 7.4210, - "RUB": 74.4208, - "TRY": 6.1247, - "AUD": 1.6072, - "BRL": 4.2682, - "CAD": 1.5128, - "CNY": 7.5857, - "HKD": 8.8743, - "IDR": 15999.40, - "ILS": 4.0875, - "INR": 79.4320, - "KRW": 1275.05, - "MXN": 21.7999, - "MYR": 4.6289, - "NZD": 1.6679, - "PHP": 59.083, - "SGD": 1.5349, - "THB": 36.012, - "ZAR": 16.0583 -} \ No newline at end of file diff --git a/examples/online-boutique/services/currency/ftl.toml b/examples/online-boutique/services/currency/ftl.toml deleted file mode 100644 index 07218ce63..000000000 --- a/examples/online-boutique/services/currency/ftl.toml +++ /dev/null @@ -1,2 +0,0 @@ -module = "currency" -language = "go" diff --git a/examples/online-boutique/services/currency/go.mod b/examples/online-boutique/services/currency/go.mod deleted file mode 100644 index cb2f5d2f0..000000000 --- a/examples/online-boutique/services/currency/go.mod +++ /dev/null @@ -1,12 +0,0 @@ -module ftl/currency - -go 1.21.6 - -replace github.com/TBD54566975/ftl => ../../../.. - -replace github.com/TBD54566975/ftl/examples/online-boutique => ../.. - -require ( - github.com/TBD54566975/ftl/examples/online-boutique v0.0.0-00010101000000-000000000000 - golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3 -) diff --git a/examples/online-boutique/services/currency/go.sum b/examples/online-boutique/services/currency/go.sum deleted file mode 100644 index 3707af3cb..000000000 --- a/examples/online-boutique/services/currency/go.sum +++ /dev/null @@ -1,2 +0,0 @@ -golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3 h1:hNQpMuAJe5CtcUqCXaWga3FHu+kQvCqcsoVaQgSV60o= -golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= diff --git a/examples/online-boutique/services/payment/ftl.toml b/examples/online-boutique/services/payment/ftl.toml deleted file mode 100644 index cd591d5bf..000000000 --- a/examples/online-boutique/services/payment/ftl.toml +++ /dev/null @@ -1,2 +0,0 @@ -module = "payment" -language = "go" diff --git a/examples/online-boutique/services/payment/go.mod b/examples/online-boutique/services/payment/go.mod deleted file mode 100644 index 807fbb01d..000000000 --- a/examples/online-boutique/services/payment/go.mod +++ /dev/null @@ -1,9 +0,0 @@ -module ftl/payment - -go 1.21.6 - -replace github.com/TBD54566975/ftl => ../../../.. - -replace github.com/TBD54566975/ftl/examples/online-boutique => ../.. - -require github.com/google/uuid v1.5.0 diff --git a/examples/online-boutique/services/payment/go.sum b/examples/online-boutique/services/payment/go.sum deleted file mode 100644 index 040e22135..000000000 --- a/examples/online-boutique/services/payment/go.sum +++ /dev/null @@ -1,2 +0,0 @@ -github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= -github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= diff --git a/examples/online-boutique/services/payment/payment.go b/examples/online-boutique/services/payment/payment.go deleted file mode 100644 index 07367031d..000000000 --- a/examples/online-boutique/services/payment/payment.go +++ /dev/null @@ -1,89 +0,0 @@ -//ftl:module payment -package payment - -import ( - "context" - "fmt" - "strings" - "time" - - "github.com/google/uuid" - - "ftl/builtin" - "ftl/currency" -) - -type InvalidCreditCardErr struct{} - -func (e InvalidCreditCardErr) Error() string { return "invalid credit card" } - -type UnacceptedCreditCardErr struct{} - -func (e UnacceptedCreditCardErr) Error() string { - return "credit card not accepted; only VISA or MasterCard are accepted" -} - -type ExpiredCreditCardErr struct{} - -func (e ExpiredCreditCardErr) Error() string { return "credit card expired" } - -type CreditCardInfo struct { - Number string - CVV int - ExpirationYear int - ExpirationMonth time.Month -} - -// LastFour returns the last four digits of the card number. -func (c CreditCardInfo) LastFour() string { - num := c.Number - if len(num) > 4 { - num = num[len(num)-4:] - } - return num -} - -type ChargeRequest struct { - Amount currency.Money - CreditCard CreditCardInfo -} - -type ChargeResponse struct { - TransactionID string -} - -//ftl:verb -//ftl:ingress POST /payment/charge -func Charge(ctx context.Context, req builtin.HttpRequest[ChargeRequest]) (builtin.HttpResponse[ChargeResponse], error) { - card := req.Body.CreditCard - number := strings.ReplaceAll(card.Number, "-", "") - var company string - switch { - case len(number) < 4: - return builtin.HttpResponse[ChargeResponse]{Body: ChargeResponse{}}, InvalidCreditCardErr{} - case number[0] == '4': - company = "Visa" - case number[0] == '5': - company = "MasterCard" - default: - return builtin.HttpResponse[ChargeResponse]{Body: ChargeResponse{}}, InvalidCreditCardErr{} - } - if card.CVV < 100 || card.CVV > 9999 { - return builtin.HttpResponse[ChargeResponse]{Body: ChargeResponse{}}, InvalidCreditCardErr{} - } - if time.Date(card.ExpirationYear, card.ExpirationMonth, 0, 0, 0, 0, 0, time.Local).Before(time.Now()) { - return builtin.HttpResponse[ChargeResponse]{Body: ChargeResponse{}}, InvalidCreditCardErr{} - } - - // Card is valid: process the transaction. - fmt.Println( - "Transaction processed", - "company", company, - "last_four", number[len(number)-4:], - "currency", req.Body.Amount.CurrencyCode, - "amount", fmt.Sprintf("%d.%d", req.Body.Amount.Units, req.Body.Amount.Nanos), - ) - return builtin.HttpResponse[ChargeResponse]{ - Body: ChargeResponse{TransactionID: uuid.New().String()}, - }, nil -} diff --git a/examples/online-boutique/services/productcatalog/database.json b/examples/online-boutique/services/productcatalog/database.json deleted file mode 100644 index 596f60137..000000000 --- a/examples/online-boutique/services/productcatalog/database.json +++ /dev/null @@ -1,110 +0,0 @@ -[ - { - "id": "OLJCESPC7Z", - "name": "Sunglasses", - "description": "Add a modern touch to your outfits with these sleek aviator sunglasses.", - "picture": "https://github.com/GoogleCloudPlatform/microservices-demo/blob/main/src/frontend/static/img/products/sunglasses.jpg?raw=true", - "priceUsd": { - "currencyCode": "USD", - "units": 19, - "nanos": 990000000 - }, - "categories": ["accessories"] - }, - { - "id": "66VCHSJNUP", - "name": "Tank Top", - "description": "Perfectly cropped cotton tank, with a scooped neckline.", - "picture": "https://github.com/GoogleCloudPlatform/microservices-demo/blob/main/src/frontend/static/img/products/tank-top.jpg?raw=true", - "priceUsd": { - "currencyCode": "USD", - "units": 18, - "nanos": 990000000 - }, - "categories": ["clothing", "tops"] - }, - { - "id": "1YMWWN1N4O", - "name": "Watch", - "description": "This gold-tone stainless steel watch will work with most of your outfits.", - "picture": "https://github.com/GoogleCloudPlatform/microservices-demo/blob/main/src/frontend/static/img/products/watch.jpg?raw=true", - "priceUsd": { - "currencyCode": "USD", - "units": 109, - "nanos": 990000000 - }, - "categories": ["accessories"] - }, - { - "id": "L9ECAV7KIM", - "name": "Loafers", - "description": "A neat addition to your summer wardrobe.", - "picture": "https://github.com/GoogleCloudPlatform/microservices-demo/blob/main/src/frontend/static/img/products/loafers.jpg?raw=true", - "priceUsd": { - "currencyCode": "USD", - "units": 89, - "nanos": 990000000 - }, - "categories": ["footwear"] - }, - { - "id": "2ZYFJ3GM2N", - "name": "Hairdryer", - "description": "This lightweight hairdryer has 3 heat and speed settings. It's perfect for travel.", - "picture": "https://github.com/GoogleCloudPlatform/microservices-demo/blob/main/src/frontend/static/img/products/hairdryer.jpg?raw=true", - "priceUsd": { - "currencyCode": "USD", - "units": 24, - "nanos": 990000000 - }, - "categories": ["hair", "beauty"] - }, - { - "id": "0PUK6V6EV0", - "name": "Candle Holder", - "description": "This small but intricate candle holder is an excellent gift.", - "picture": "https://github.com/GoogleCloudPlatform/microservices-demo/blob/main/src/frontend/static/img/products/candle-holder.jpg?raw=true", - "priceUsd": { - "currencyCode": "USD", - "units": 18, - "nanos": 990000000 - }, - "categories": ["decor", "home"] - }, - { - "id": "LS4PSXUNUM", - "name": "Salt & Pepper Shakers", - "description": "Add some flavor to your kitchen.", - "picture": "https://github.com/GoogleCloudPlatform/microservices-demo/blob/main/src/frontend/static/img/products/salt-and-pepper-shakers.jpg?raw=true", - "priceUsd": { - "currencyCode": "USD", - "units": 18, - "nanos": 490000000 - }, - "categories": ["kitchen"] - }, - { - "id": "9SIQT8TOJO", - "name": "Bamboo Glass Jar", - "description": "This bamboo glass jar can hold 57 oz (1.7 l) and is perfect for any kitchen.", - "picture": "https://raw.githubusercontent.com/GoogleCloudPlatform/microservices-demo/main/src/frontend/static/img/products/bamboo-glass-jar.jpg", - "priceUsd": { - "currencyCode": "USD", - "units": 5, - "nanos": 490000000 - }, - "categories": ["kitchen"] - }, - { - "id": "6E92ZMYYFZ", - "name": "Mug", - "description": "A simple mug with a mustard interior.", - "picture": "https://github.com/GoogleCloudPlatform/microservices-demo/blob/main/src/frontend/static/img/products/mug.jpg?raw=true", - "priceUsd": { - "currencyCode": "USD", - "units": 8, - "nanos": 990000000 - }, - "categories": ["kitchen"] - } -] diff --git a/examples/online-boutique/services/productcatalog/ftl.toml b/examples/online-boutique/services/productcatalog/ftl.toml deleted file mode 100644 index b66dc4976..000000000 --- a/examples/online-boutique/services/productcatalog/ftl.toml +++ /dev/null @@ -1,2 +0,0 @@ -module = "productcatalog" -language = "go" diff --git a/examples/online-boutique/services/productcatalog/go.mod b/examples/online-boutique/services/productcatalog/go.mod deleted file mode 100644 index fb4855ad2..000000000 --- a/examples/online-boutique/services/productcatalog/go.mod +++ /dev/null @@ -1,9 +0,0 @@ -module ftl/productcatalog - -go 1.21.6 - -replace github.com/TBD54566975/ftl => ../../../.. - -replace github.com/TBD54566975/ftl/examples/online-boutique => ../.. - -require github.com/TBD54566975/ftl/examples/online-boutique v0.0.0-00010101000000-000000000000 diff --git a/examples/online-boutique/services/productcatalog/productcatalog.go b/examples/online-boutique/services/productcatalog/productcatalog.go deleted file mode 100644 index e0c8727d5..000000000 --- a/examples/online-boutique/services/productcatalog/productcatalog.go +++ /dev/null @@ -1,81 +0,0 @@ -//ftl:module productcatalog -package productcatalog - -import ( - "context" - _ "embed" - "fmt" - "strings" - - "ftl/builtin" - "ftl/currency" - - "github.com/TBD54566975/ftl/examples/online-boutique/common" -) - -var ( - //go:embed database.json - databaseJSON []byte - database = common.LoadDatabase[[]Product](databaseJSON) -) - -type Product struct { - ID string `json:"id"` - Name string `json:"name"` - Description string `json:"description"` - Picture string `json:"picture"` - PriceUSD currency.Money `json:"priceUSD"` - - // Categories such as "clothing" or "kitchen" that can be used to look up - // other related products. - Categories []string `json:"categories"` -} - -type ListRequest struct{} - -type ListResponse struct { - Products []Product `json:"products"` -} - -//ftl:verb -//ftl:ingress GET /productcatalog -func List(ctx context.Context, req builtin.HttpRequest[ListRequest]) (builtin.HttpResponse[ListResponse], error) { - return builtin.HttpResponse[ListResponse]{ - Body: ListResponse{Products: database}, - }, nil -} - -type GetRequest struct { - ID string -} - -//ftl:verb -//ftl:ingress GET /productcatalog/{id} -func Get(ctx context.Context, req builtin.HttpRequest[GetRequest]) (builtin.HttpResponse[Product], error) { - for _, p := range database { - if p.ID == req.Body.ID { - return builtin.HttpResponse[Product]{Body: p}, nil - } - } - return builtin.HttpResponse[Product]{Body: Product{}}, fmt.Errorf("product not found: %q", req.Body.ID) -} - -type SearchRequest struct { - Query string -} - -type SearchResponse struct { - Results []Product -} - -//ftl:verb -func Search(ctx context.Context, req SearchRequest) (SearchResponse, error) { - out := SearchResponse{} - q := strings.ToLower(req.Query) - for _, p := range database { - if strings.Contains(strings.ToLower(p.Name), q) || strings.Contains(strings.ToLower(p.Description), q) { - out.Results = append(out.Results, p) - } - } - return out, nil -} diff --git a/examples/online-boutique/services/recommendation/ftl.toml b/examples/online-boutique/services/recommendation/ftl.toml deleted file mode 100644 index b9adcbd93..000000000 --- a/examples/online-boutique/services/recommendation/ftl.toml +++ /dev/null @@ -1,2 +0,0 @@ -module = "recommendation" -language = "go" diff --git a/examples/online-boutique/services/recommendation/go.mod b/examples/online-boutique/services/recommendation/go.mod deleted file mode 100644 index 8bc48c240..000000000 --- a/examples/online-boutique/services/recommendation/go.mod +++ /dev/null @@ -1,47 +0,0 @@ -module ftl/recommendation - -go 1.22.0 - -replace github.com/TBD54566975/ftl => ../../../.. - -replace github.com/TBD54566975/ftl/examples/online-boutique => ../.. - -require github.com/TBD54566975/ftl v0.0.0-00010101000000-000000000000 - -require ( - connectrpc.com/connect v1.14.0 // indirect - connectrpc.com/grpcreflect v1.2.0 // indirect - connectrpc.com/otelconnect v0.7.0 // indirect - github.com/alecthomas/concurrency v0.0.2 // indirect - github.com/alecthomas/participle/v2 v2.1.1 // indirect - github.com/alecthomas/types v0.10.1 // indirect - github.com/alessio/shellescape v1.4.2 // indirect - github.com/danieljoos/wincred v1.2.0 // indirect - github.com/go-logr/logr v1.4.1 // indirect - github.com/go-logr/stdr v1.2.2 // indirect - github.com/godbus/dbus/v5 v5.1.0 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/jackc/pgpassfile v1.0.0 // indirect - github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect - github.com/jackc/pgx/v5 v5.5.3 // indirect - github.com/jackc/puddle/v2 v2.2.1 // indirect - github.com/jpillora/backoff v1.0.0 // indirect - github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect - github.com/oklog/ulid/v2 v2.1.0 // indirect - github.com/swaggest/jsonschema-go v0.3.64 // indirect - github.com/swaggest/refl v1.3.0 // indirect - github.com/zalando/go-keyring v0.2.3 // indirect - go.opentelemetry.io/otel v1.23.1 // indirect - go.opentelemetry.io/otel/metric v1.23.1 // indirect - go.opentelemetry.io/otel/trace v1.23.1 // indirect - golang.design/x/reflect v0.0.0-20220504060917-02c43be63f3b // indirect - golang.org/x/crypto v0.19.0 // indirect - golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 // indirect - golang.org/x/mod v0.15.0 // indirect - golang.org/x/net v0.21.0 // indirect - golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/text v0.14.0 // indirect - google.golang.org/protobuf v1.32.0 // indirect -) diff --git a/examples/online-boutique/services/recommendation/go.sum b/examples/online-boutique/services/recommendation/go.sum deleted file mode 100644 index 1650df7dd..000000000 --- a/examples/online-boutique/services/recommendation/go.sum +++ /dev/null @@ -1,143 +0,0 @@ -connectrpc.com/connect v1.14.0 h1:PDS+J7uoz5Oui2VEOMcfz6Qft7opQM9hPiKvtGC01pA= -connectrpc.com/connect v1.14.0/go.mod h1:uoAq5bmhhn43TwhaKdGKN/bZcGtzPW1v+ngDTn5u+8s= -connectrpc.com/grpcreflect v1.2.0 h1:Q6og1S7HinmtbEuBvARLNwYmTbhEGRpHDhqrPNlmK+U= -connectrpc.com/grpcreflect v1.2.0/go.mod h1:nwSOKmE8nU5u/CidgHtPYk1PFI3U9ignz7iDMxOYkSY= -connectrpc.com/otelconnect v0.7.0 h1:ZH55ZZtcJOTKWWLy3qmL4Pam4RzRWBJFOqTPyAqCXkY= -connectrpc.com/otelconnect v0.7.0/go.mod h1:Bt2ivBymHZHqxvo4HkJ0EwHuUzQN6k2l0oH+mp/8nwc= -github.com/alecthomas/assert/v2 v2.5.0 h1:OJKYg53BQx06/bMRBSPDCO49CbCDNiUQXwdoNrt6x5w= -github.com/alecthomas/assert/v2 v2.5.0/go.mod h1:fw5suVxB+wfYJ3291t0hRTqtGzFYdSwstnRQdaQx2DM= -github.com/alecthomas/concurrency v0.0.2 h1:Q3kGPtLbleMbH9lHX5OBFvJygfyFw29bXZKBg+IEVuo= -github.com/alecthomas/concurrency v0.0.2/go.mod h1:GmuQb/iHX7mbNtPlC/WDzEFxDMB0HYFer2Qda9QTs7w= -github.com/alecthomas/participle/v2 v2.1.1 h1:hrjKESvSqGHzRb4yW1ciisFJ4p3MGYih6icjJvbsmV8= -github.com/alecthomas/participle/v2 v2.1.1/go.mod h1:Y1+hAs8DHPmc3YUFzqllV+eSQ9ljPTk0ZkPMtEdAx2c= -github.com/alecthomas/repr v0.3.0 h1:NeYzUPfjjlqHY4KtzgKJiWd6sVq2eNUPTi34PiFGjY8= -github.com/alecthomas/repr v0.3.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= -github.com/alecthomas/types v0.10.1 h1:PuBMoHpFL2jaW3VgPDRhCk1oKoBCzfbsL5sAxEc3U3A= -github.com/alecthomas/types v0.10.1/go.mod h1:fIOGnLeeUJXe1AAVofQmMaEMWLxY9bK4QxTLGIo30PA= -github.com/alessio/shellescape v1.4.2 h1:MHPfaU+ddJ0/bYWpgIeUnQUqKrlJ1S7BfEYPM4uEoM0= -github.com/alessio/shellescape v1.4.2/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30= -github.com/bool64/dev v0.2.31 h1:OS57EqYaYe2M/2bw9uhDCIFiZZwywKFS/4qMLN6JUmQ= -github.com/bool64/dev v0.2.31/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8ACg= -github.com/bool64/shared v0.1.5 h1:fp3eUhBsrSjNCQPcSdQqZxxh9bBwrYiZ+zOKFkM0/2E= -github.com/bool64/shared v0.1.5/go.mod h1:081yz68YC9jeFB3+Bbmno2RFWvGKv1lPKkMP6MHJlPs= -github.com/danieljoos/wincred v1.2.0 h1:ozqKHaLK0W/ii4KVbbvluM91W2H3Sh0BncbUNPS7jLE= -github.com/danieljoos/wincred v1.2.0/go.mod h1:FzQLLMKBFdvu+osBrnFODiv32YGwCfx0SkRa/eYHgec= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= -github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= -github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= -github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= -github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= -github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= -github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc= -github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE= -github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= -github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= -github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk= -github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= -github.com/jackc/pgx/v5 v5.5.3 h1:Ces6/M3wbDXYpM8JyyPD57ivTtJACFZJd885pdIaV2s= -github.com/jackc/pgx/v5 v5.5.3/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A= -github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk= -github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= -github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA= -github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= -github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= -github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/oklog/ulid/v2 v2.1.0 h1:+9lhoxAP56we25tyYETBBY1YLA2SaoLvUFgrP2miPJU= -github.com/oklog/ulid/v2 v2.1.0/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ= -github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= -github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= -github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 h1:lZUw3E0/J3roVtGQ+SCrUrg3ON6NgVqpn3+iol9aGu4= -github.com/santhosh-tekuri/jsonschema/v5 v5.3.1/go.mod h1:uToXkOrWAZ6/Oc07xWQrPOhJotwFIyu2bBVN41fcDUY= -github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= -github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/swaggest/assertjson v1.9.0 h1:dKu0BfJkIxv/xe//mkCrK5yZbs79jL7OVf9Ija7o2xQ= -github.com/swaggest/assertjson v1.9.0/go.mod h1:b+ZKX2VRiUjxfUIal0HDN85W0nHPAYUbYH5WkkSsFsU= -github.com/swaggest/jsonschema-go v0.3.64 h1:HyB41fkA4XP0BZkqWfGap5i2JtRHQGXG/21dGDPbyLM= -github.com/swaggest/jsonschema-go v0.3.64/go.mod h1:DYuKqdpms/edvywsX6p1zHXCZkdwB28wRaBdFCe3Duw= -github.com/swaggest/refl v1.3.0 h1:PEUWIku+ZznYfsoyheF97ypSduvMApYyGkYF3nabS0I= -github.com/swaggest/refl v1.3.0/go.mod h1:3Ujvbmh1pfSbDYjC6JGG7nMgPvpG0ehQL4iNonnLNbg= -github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCOA= -github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= -github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3IfnEUduWvb9is428/nNb5L3U01M= -github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= -github.com/zalando/go-keyring v0.2.3 h1:v9CUu9phlABObO4LPWycf+zwMG7nlbb3t/B5wa97yms= -github.com/zalando/go-keyring v0.2.3/go.mod h1:HL4k+OXQfJUWaMnqyuSOc0drfGPX2b51Du6K+MRgZMk= -go.opentelemetry.io/otel v1.23.1 h1:Za4UzOqJYS+MUczKI320AtqZHZb7EqxO00jAHE0jmQY= -go.opentelemetry.io/otel v1.23.1/go.mod h1:Td0134eafDLcTS4y+zQ26GE8u3dEuRBiBCTUIRHaikA= -go.opentelemetry.io/otel/metric v1.23.1 h1:PQJmqJ9u2QaJLBOELl1cxIdPcpbwzbkjfEyelTl2rlo= -go.opentelemetry.io/otel/metric v1.23.1/go.mod h1:mpG2QPlAfnK8yNhNJAxDZruU9Y1/HubbC+KyH8FaCWI= -go.opentelemetry.io/otel/sdk v1.23.1 h1:O7JmZw0h76if63LQdsBMKQDWNb5oEcOThG9IrxscV+E= -go.opentelemetry.io/otel/sdk v1.23.1/go.mod h1:LzdEVR5am1uKOOwfBWFef2DCi1nu3SA8XQxx2IerWFk= -go.opentelemetry.io/otel/sdk/metric v1.23.1 h1:T9/8WsYg+ZqIpMWwdISVVrlGb/N0Jr1OHjR/alpKwzg= -go.opentelemetry.io/otel/sdk/metric v1.23.1/go.mod h1:8WX6WnNtHCgUruJ4TJ+UssQjMtpxkpX0zveQC8JG/E0= -go.opentelemetry.io/otel/trace v1.23.1 h1:4LrmmEd8AU2rFvU1zegmvqW7+kWarxtNOPyeL6HmYY8= -go.opentelemetry.io/otel/trace v1.23.1/go.mod h1:4IpnpJFwr1mo/6HL8XIPJaE9y0+u1KcVmuW7dwFSVrI= -golang.design/x/reflect v0.0.0-20220504060917-02c43be63f3b h1:lkOPTy76R9NZ6FeDQWkDj3NsLtD8Csc9AAFYEl3kiME= -golang.design/x/reflect v0.0.0-20220504060917-02c43be63f3b/go.mod h1:QXG482h3unP32W/YwIPOc+09bvY447B7T+iLjC/JPcA= -golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= -golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= -golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 h1:/RIbNt/Zr7rVhIkQhooTxCxFcdWLGIKnZA4IXNFSrvo= -golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= -golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= -golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= -golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= -google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= -google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -lukechampine.com/uint128 v1.2.0 h1:mBi/5l91vocEN8otkC5bDLhi2KdCticRiwbdB0O+rjI= -lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= -modernc.org/cc/v3 v3.40.0 h1:P3g79IUS/93SYhtoeaHW+kRCIrYaxJ27MFPv+7kaTOw= -modernc.org/cc/v3 v3.40.0/go.mod h1:/bTg4dnWkSXowUO6ssQKnOV0yMVxDYNIsIrzqTFDGH0= -modernc.org/ccgo/v3 v3.16.13 h1:Mkgdzl46i5F/CNR/Kj80Ri59hC8TKAhZrYSaqvkwzUw= -modernc.org/ccgo/v3 v3.16.13/go.mod h1:2Quk+5YgpImhPjv2Qsob1DnZ/4som1lJTodubIcoUkY= -modernc.org/libc v1.29.0 h1:tTFRFq69YKCF2QyGNuRUQxKBm1uZZLubf6Cjh/pVHXs= -modernc.org/libc v1.29.0/go.mod h1:DaG/4Q3LRRdqpiLyP0C2m1B8ZMGkQ+cCgOIjEtQlYhQ= -modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4= -modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo= -modernc.org/memory v1.7.2 h1:Klh90S215mmH8c9gO98QxQFsY+W451E8AnzjoE2ee1E= -modernc.org/memory v1.7.2/go.mod h1:NO4NVCQy0N7ln+T9ngWqOQfi7ley4vpwvARR+Hjw95E= -modernc.org/opt v0.1.3 h1:3XOZf2yznlhC+ibLltsDGzABUGVx8J6pnFMS3E4dcq4= -modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= -modernc.org/sqlite v1.28.0 h1:Zx+LyDDmXczNnEQdvPuEfcFVA2ZPyaD7UCZDjef3BHQ= -modernc.org/sqlite v1.28.0/go.mod h1:Qxpazz0zH8Z1xCFyi5GSL3FzbtZ3fvbjmywNogldEW0= -modernc.org/strutil v1.1.3 h1:fNMm+oJklMGYfU9Ylcywl0CO5O6nTfaowNsh2wpPjzY= -modernc.org/strutil v1.1.3/go.mod h1:MEHNA7PdEnEwLvspRMtWTNnp2nnyvMfkimT1NKNAGbw= -modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y= -modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= diff --git a/examples/online-boutique/services/recommendation/recommendation.go b/examples/online-boutique/services/recommendation/recommendation.go deleted file mode 100644 index 85d990d8d..000000000 --- a/examples/online-boutique/services/recommendation/recommendation.go +++ /dev/null @@ -1,58 +0,0 @@ -//ftl:module recommendation -package recommendation - -import ( - "context" - "fmt" - "math/rand" - - "ftl/builtin" - "ftl/productcatalog" - - ftl "github.com/TBD54566975/ftl/go-runtime/ftl" -) - -type ListRequest struct { - UserID string - UserProductIDs []string -} - -type ListResponse struct { - ProductIDs []string -} - -//ftl:verb -//ftl:ingress GET /recommendation -func List(ctx context.Context, req builtin.HttpRequest[ListRequest]) (builtin.HttpResponse[ListResponse], error) { - cresp, err := ftl.Call(ctx, productcatalog.List, builtin.HttpRequest[productcatalog.ListRequest]{}) - if err != nil { - return builtin.HttpResponse[ListResponse]{Body: ListResponse{}}, fmt.Errorf("%s: %w", "failed to retrieve product catalog", err) - } - - // Remove user-provided products from the catalog, to avoid recommending - // them. - userIDs := make(map[string]struct{}, len(req.Body.UserProductIDs)) - for _, id := range req.Body.UserProductIDs { - userIDs[id] = struct{}{} - } - filtered := make([]string, 0, len(cresp.Body.Products)) - for _, product := range cresp.Body.Products { - if _, ok := userIDs[product.Id]; ok { - continue - } - filtered = append(filtered, product.Id) - } - - // Sample from filtered products and return them. - perm := rand.Perm(len(filtered)) - const maxResponses = 5 - ret := make([]string, 0, maxResponses) - for _, idx := range perm { - ret = append(ret, filtered[idx]) - if len(ret) >= maxResponses { - break - } - } - return builtin.HttpResponse[ListResponse]{Body: ListResponse{ProductIDs: ret}}, nil - -} diff --git a/examples/online-boutique/services/shipping/ftl.toml b/examples/online-boutique/services/shipping/ftl.toml deleted file mode 100644 index c7cbbc525..000000000 --- a/examples/online-boutique/services/shipping/ftl.toml +++ /dev/null @@ -1,2 +0,0 @@ -module = "shipping" -language = "go" diff --git a/examples/online-boutique/services/shipping/go.mod b/examples/online-boutique/services/shipping/go.mod deleted file mode 100644 index 7d0bcf2c1..000000000 --- a/examples/online-boutique/services/shipping/go.mod +++ /dev/null @@ -1,7 +0,0 @@ -module ftl/shipping - -go 1.21.6 - -replace github.com/TBD54566975/ftl => ../../../.. - -replace github.com/TBD54566975/ftl/examples/online-boutique => ../.. diff --git a/examples/online-boutique/services/shipping/shipping.go b/examples/online-boutique/services/shipping/shipping.go deleted file mode 100644 index 455ac21f6..000000000 --- a/examples/online-boutique/services/shipping/shipping.go +++ /dev/null @@ -1,51 +0,0 @@ -//ftl:module shipping -package shipping - -import ( - "context" - "fmt" - "math" - - "ftl/builtin" - "ftl/cart" - "ftl/currency" -) - -type Address struct { - StreetAddress string - City string - State string - Country string - ZipCode int -} - -type ShippingRequest struct { - Address Address - Items []cart.Item -} - -//ftl:verb -//ftl:ingress POST /shipping/quote -func GetQuote(ctx context.Context, req builtin.HttpRequest[ShippingRequest]) (builtin.HttpResponse[currency.Money], error) { - return builtin.HttpResponse[currency.Money]{Body: moneyFromUSD(8.99)}, nil -} - -type ShipOrderResponse struct { - ID string -} - -//ftl:verb -//ftl:ingress POST /shipping/ship -func ShipOrder(ctx context.Context, req builtin.HttpRequest[ShippingRequest]) (builtin.HttpResponse[ShipOrderResponse], error) { - baseAddress := fmt.Sprintf("%s, %s, %s", req.Body.Address.StreetAddress, req.Body.Address.City, req.Body.Address.State) - return builtin.HttpResponse[ShipOrderResponse]{Body: ShipOrderResponse{ID: createTrackingID(baseAddress)}}, nil -} - -func moneyFromUSD(value float64) currency.Money { - units, fraction := math.Modf(value) - return currency.Money{ - CurrencyCode: "USD", - Units: int(units), - Nanos: int(math.Trunc(fraction * 10000000)), - } -} diff --git a/examples/online-boutique/services/shipping/tracking.go b/examples/online-boutique/services/shipping/tracking.go deleted file mode 100644 index dd89090e9..000000000 --- a/examples/online-boutique/services/shipping/tracking.go +++ /dev/null @@ -1,47 +0,0 @@ -package shipping - -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import ( - "fmt" - "math/rand" -) - -// createTrackingID generates a tracking ID. -func createTrackingID(salt string) string { - return fmt.Sprintf("%c%c-%d%s-%d%s", - getRandomLetterCode(), - getRandomLetterCode(), - len(salt), - getRandomNumber(3), - len(salt)/2, - getRandomNumber(7), - ) -} - -// getRandomLetterCode generates a code point value for a capital letter. -func getRandomLetterCode() uint32 { - return 65 + uint32(rand.Intn(25)) -} - -// getRandomNumber generates a string representation of a number with the requested number of digits. -func getRandomNumber(digits int) string { - str := "" - for i := 0; i < digits; i++ { - str = fmt.Sprintf("%s%d", str, rand.Intn(10)) - } - - return str -}