Skip to content

Commit

Permalink
Merge pull request #299 from drift-labs/master
Browse files Browse the repository at this point in the history
staging
  • Loading branch information
NourAlharithi authored Dec 5, 2024
2 parents 9ebf018 + a25b845 commit af74474
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 4 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# non-prod
name: DLOB Build Image And Deploy

on:
push:
branches: [master, staging]

jobs:
build:
runs-on: ubicloud
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
submodules: recursive

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@master
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_NON_PROD }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY_NON_PROD }}
aws-region: ${{ secrets.EKS_NON_PROD_REGION }}

- name: Log in to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Build and push
uses: docker/build-push-action@v6
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: dlob-server
IMAGE_TAG: ${{ github.sha }}
BRANCH_NAME: ${{ github.ref_name }}
with:
context: .
push: true
tags: |
${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}
${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest-${{ env.BRANCH_NAME }}-amd64
deploy:
runs-on: ubicloud
needs: [build]
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@master
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_NON_PROD }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY_NON_PROD }}
aws-region: ${{ secrets.EKS_NON_PROD_REGION }}

- name: Install kubectl
uses: azure/setup-kubectl@v3
with:
version: 'v1.30.0'

- name: Configure AWS EKS Credentials
run: aws eks update-kubeconfig --name ${{ secrets.EKS_NON_PROD_CLUSTER_NAME }} --region ${{ secrets.EKS_NON_PROD_REGION }} --role-arn ${{ secrets.EKS_NON_PROD_DEPLOY_ROLE }}

- name: Restart deployment
env:
BRANCH_NAME: ${{ github.ref_name }}
run: |
kubectl get deployments -n $BRANCH_NAME -o name | grep '^deployment.apps/dlob-publisher-app' | xargs -I {} kubectl rollout restart {} -n $BRANCH_NAME
kubectl rollout restart -n $BRANCH_NAME deployment/dlob-server-app
kubectl rollout restart -n $BRANCH_NAME deployment/dlob-server-lite-app
kubectl rollout restart -n $BRANCH_NAME deployment/dlob-ws-connection-manager-app
kubectl rollout restart -n $BRANCH_NAME deployment/dlob-trades-publisher-app
kubectl rollout restart -n $BRANCH_NAME deployment/dlob-priority-fees-publisher-app
2 changes: 1 addition & 1 deletion drift-common
2 changes: 0 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -650,8 +650,6 @@ const main = async (): Promise<void> => {
const depth = Math.min(parseInt(adjustedDepth as string) ?? 1, 100);
redisL2['bids'] = redisL2['bids']?.slice(0, depth);
redisL2['asks'] = redisL2['asks']?.slice(0, depth);
console.log(redisL2['slot']);
console.log(SLOT_STALENESS_TOLERANCE);
if (
redisL2 &&
dlobProvider.getSlot() - redisL2['slot'] < SLOT_STALENESS_TOLERANCE
Expand Down
19 changes: 18 additions & 1 deletion src/publishers/dlobPublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,24 @@ const main = async () => {
let accountSubscription: DriftClientSubscriptionConfig;
let slotSource: SlotSource;

if (!useWebsocket) {
// USE_GRPC=true will override websocket
if (useGrpc) {
accountSubscription = {
type: 'grpc',
resubTimeoutMs: 30_000,
grpcConfigs: {
endpoint,
token,
},
};

slotSubscriber = new SlotSubscriber(connection);
await slotSubscriber.subscribe();

slotSource = {
getSlot: () => slotSubscriber!.getSlot(),
};
} else if (!useWebsocket) {
bulkAccountLoader = new BulkAccountLoader(
connection,
stateCommitment,
Expand Down

0 comments on commit af74474

Please sign in to comment.