update cart deployment
This commit is contained in:
31
main.go
31
main.go
@@ -3,12 +3,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
messages "git.tornberg.me/go-cart-actor/proto"
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
|
||||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
|
||||||
"k8s.io/client-go/kubernetes"
|
|
||||||
"k8s.io/client-go/rest"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/pprof"
|
"net/http/pprof"
|
||||||
@@ -16,6 +10,13 @@ import (
|
|||||||
"os/signal"
|
"os/signal"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
messages "git.tornberg.me/go-cart-actor/proto"
|
||||||
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||||
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
|
"k8s.io/client-go/kubernetes"
|
||||||
|
"k8s.io/client-go/rest"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -127,6 +128,14 @@ var tpl = `<!DOCTYPE html>
|
|||||||
`
|
`
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
baseUrl := os.Getenv("BASE_URL")
|
||||||
|
cartBaseUrl := os.Getenv("CART_BASE_URL")
|
||||||
|
if cartBaseUrl == "" {
|
||||||
|
cartBaseUrl = "https://cart.tornberg.me"
|
||||||
|
}
|
||||||
|
if baseUrl == "" {
|
||||||
|
baseUrl = "https://slask-finder.tornberg.me"
|
||||||
|
}
|
||||||
// Create a new instance of the server
|
// Create a new instance of the server
|
||||||
storage, err := NewDiskStorage(fmt.Sprintf("data/%s_state.gob", name))
|
storage, err := NewDiskStorage(fmt.Sprintf("data/%s_state.gob", name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -216,11 +225,11 @@ func main() {
|
|||||||
reply, err := syncedServer.pool.Process(cartId, Message{
|
reply, err := syncedServer.pool.Process(cartId, Message{
|
||||||
Type: CreateCheckoutOrderType,
|
Type: CreateCheckoutOrderType,
|
||||||
Content: &messages.CreateCheckoutOrder{
|
Content: &messages.CreateCheckoutOrder{
|
||||||
Terms: "https://slask-finder.tornberg.me/terms",
|
Terms: fmt.Sprintf("%s/terms", baseUrl),
|
||||||
Checkout: "https://slask-finder.tornberg.me/checkout?order_id={checkout.order.id}",
|
Checkout: fmt.Sprintf("%s/checkout?order_id={checkout.order.id}", baseUrl),
|
||||||
Confirmation: "https://slask-finder.tornberg.me/confirmation/{checkout.order.id}",
|
Confirmation: fmt.Sprintf("%s/confirmation/{checkout.order.id}", baseUrl),
|
||||||
Validation: "https://cart.tornberg.me/validation",
|
Validation: fmt.Sprintf("%s/validation", cartBaseUrl),
|
||||||
Push: "https://cart.tornberg.me/push?order_id={checkout.order.id}",
|
Push: fmt.Sprintf("%s/push?order_id={checkout.order.id}", cartBaseUrl),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -2,15 +2,26 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/matst80/slask-finder/pkg/index"
|
"github.com/matst80/slask-finder/pkg/index"
|
||||||
)
|
)
|
||||||
|
|
||||||
/** end */
|
/** end */
|
||||||
|
var baseUrl string
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
baseUrl = "https://slask-finder.tornberg.me"
|
||||||
|
envUrl := os.Getenv("BASE_URL")
|
||||||
|
if envUrl != "" {
|
||||||
|
baseUrl = envUrl
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func FetchItem(sku string) (*index.DataItem, error) {
|
func FetchItem(sku string) (*index.DataItem, error) {
|
||||||
res, err := http.Get("https://slask-finder.tornberg.me/api/by-sku/" + sku)
|
res, err := http.Get(fmt.Sprintf("%s/api/by-sku/%s", baseUrl, sku))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user