Skip to content

Commit

Permalink
feat: replace apisix with traefik plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Candinya committed Mar 22, 2024
1 parent 8f65925 commit 6231d96
Show file tree
Hide file tree
Showing 38 changed files with 257 additions and 1,629 deletions.
69 changes: 0 additions & 69 deletions .github/testing/apisix/apisix.yaml

This file was deleted.

28 changes: 0 additions & 28 deletions .github/testing/apisix/config.yaml

This file was deleted.

14 changes: 3 additions & 11 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- 6379:6379

etcd:
image: bitnami/etcd:3.4.15
image: bitnami/etcd:3.5.12
env:
ETCD_ENABLE_V2: "true"
ALLOW_NONE_AUTHENTICATION: "yes"
Expand All @@ -42,22 +42,13 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Start APISix container
run: |
docker run -d --name apisix \
--network ${{ job.container.network }} --network-alias apisix \
-p 9180:9180/tcp -p 9080:9080/tcp -p 9091:9091/tcp -p 9443:9443/tcp \
-e GITHUB_ACTIONS=true -e CI=true \
-v "${{ github.workspace }}/.github/testing/apisix/config.yaml":"/usr/local/apisix/conf/config.yaml" \
-v "${{ github.workspace }}/.github/testing/apisix/apisix.yaml":"/usr/local/apisix/conf/apisix.yaml" \
apache/apisix:3.6.0-debian
- name: Start Redpanda container
run: |
docker run -d --name redpanda-0 \
--network ${{ job.container.network }} --network-alias redpanda-0 \
-p 9092:9092 -p 18081:18081 -p 18082:18082 -p 19092:19092 -p 19644:9644 \
-e GITHUB_ACTIONS=true -e CI=true \
docker.redpanda.com/redpandadata/redpanda:v23.2.12 \
docker.redpanda.com/redpandadata/redpanda:v23.3.9 \
redpanda start \
--kafka-addr internal://0.0.0.0:9092,external://0.0.0.0:19092 \
--advertise-kafka-addr internal://redpanda-0:9092,external://localhost:19092 \
Expand All @@ -70,6 +61,7 @@ jobs:
--memory 1G \
--mode dev-container \
--default-log-level=debug
- name: Start CRDB container
run: |
docker run -d --name crdb \
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ endif

lint:
go mod tidy
go run github.com/golangci/golangci-lint/cmd/[email protected] run
go run github.com/golangci/golangci-lint/cmd/[email protected] run --fix

test:
go test -cover -race -v ./...
Expand All @@ -25,7 +25,7 @@ image:
run:
ENVIRONMENT=development go run ./cmd

OAPI_SPEC ?= spec/gateway.yml
OAPI_SPEC ?= docs/gateway.yml
OAPI_TARGET ?= internal/service/gateway/gen/oapi/
OAPI_TARGET_FILENAME ?= oapi.go
gengatewayapi:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ The RSS3 Billing Gateway

<!-- We use MIT as it's almost unrestricted. -->

[MIT](MIT).
[MIT](LICENSE).
90 changes: 0 additions & 90 deletions client/client.go

This file was deleted.

24 changes: 9 additions & 15 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package main
import (
"context"
"fmt"
"github.com/rss3-network/gateway-common/control"
"os"
"os/signal"

"github.com/naturalselectionlabs/rss3-gateway/common/apisix"
"github.com/naturalselectionlabs/rss3-gateway/internal/config"
"github.com/naturalselectionlabs/rss3-gateway/internal/config/flag"
"github.com/naturalselectionlabs/rss3-gateway/internal/database/dialer"
Expand Down Expand Up @@ -41,16 +41,13 @@ var indexCommand = &cobra.Command{
return fmt.Errorf("migrate database: %w", err)
}

// Initialize APISIX configurations
apisixClient, err := apisix.New(
config.APISixAdmin.Endpoint,
config.APISixAdmin.Key,
)
// Initialize control configurations
controlClient, err := control.NewWriter(config.Gateway.Etcd.Endpoints)
if err != nil {
return fmt.Errorf("prepare apisix httpapi service: %w", err)
return fmt.Errorf("prepare control service: %w", err)
}

instance, err := indexer.New(databaseClient, apisixClient, config.Billing.RuPerToken, *config.RSS3Chain)
instance, err := indexer.New(databaseClient, controlClient, config.Billing.RuPerToken, *config.RSS3Chain)
if err != nil {
return err
}
Expand Down Expand Up @@ -121,16 +118,13 @@ var command = &cobra.Command{

redisClient := redis.NewClient(options)

// Initialize APISIX configurations
apisixClient, err := apisix.New(
config.APISixAdmin.Endpoint,
config.APISixAdmin.Key,
)
// Initialize control configurations
controlClient, err := control.NewWriter(config.Gateway.Etcd.Endpoints)
if err != nil {
return fmt.Errorf("prepare apisix httpapi service: %w", err)
return fmt.Errorf("prepare control service: %w", err)
}

instance, err := gateway.New(databaseClient, redisClient, apisixClient, *config.Gateway)
instance, err := gateway.New(databaseClient, redisClient, controlClient, *config.Gateway)
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit 6231d96

Please sign in to comment.