Skip to content

Commit

Permalink
Revert "feat(cdp): Use cyclotron part 2 (#24746)"
Browse files Browse the repository at this point in the history
This reverts commit 7fd0fbb.
  • Loading branch information
benjackwhite committed Sep 10, 2024
1 parent 7fd0fbb commit 937b012
Show file tree
Hide file tree
Showing 29 changed files with 529 additions and 1,069 deletions.
29 changes: 13 additions & 16 deletions .github/workflows/ci-plugin-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
defaults:
run:
working-directory: 'plugin-server'

steps:
- uses: actions/checkout@v3

Expand All @@ -81,7 +82,6 @@ jobs:
tests:
name: Plugin Server Tests (${{matrix.shard}})
needs: changes
if: needs.changes.outputs.plugin-server == 'true'
runs-on: ubuntu-latest

strategy:
Expand All @@ -97,17 +97,21 @@ jobs:

steps:
- name: Code check out
if: needs.changes.outputs.plugin-server == 'true'
uses: actions/checkout@v3

- name: Stop/Start stack with Docker Compose
if: needs.changes.outputs.plugin-server == 'true'
run: |
docker compose -f docker-compose.dev.yml down
docker compose -f docker-compose.dev.yml up -d
- name: Add Kafka to /etc/hosts
if: needs.changes.outputs.plugin-server == 'true'
run: echo "127.0.0.1 kafka" | sudo tee -a /etc/hosts

- name: Set up Python
if: needs.changes.outputs.plugin-server == 'true'
uses: actions/setup-python@v5
with:
python-version: 3.11.9
Expand All @@ -118,57 +122,50 @@ jobs:
# uv is a fast pip alternative: https://github.com/astral-sh/uv/
- run: pip install uv

- name: Install rust
uses: dtolnay/[email protected]

- uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
rust/target
key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}

- name: Install sqlx-cli
working-directory: rust
run: cargo install [email protected] --no-default-features --features native-tls,postgres

- name: Install SAML (python3-saml) dependencies
if: needs.changes.outputs.plugin-server == 'true'
run: |
sudo apt-get update
sudo apt-get install libxml2-dev libxmlsec1-dev libxmlsec1-openssl
- name: Install python dependencies
if: needs.changes.outputs.plugin-server == 'true'
run: |
uv pip install --system -r requirements-dev.txt
uv pip install --system -r requirements.txt
- name: Install pnpm
if: needs.changes.outputs.plugin-server == 'true'
uses: pnpm/action-setup@v4

- name: Set up Node.js
if: needs.changes.outputs.plugin-server == 'true'
uses: actions/setup-node@v4
with:
node-version: 18.12.1
cache: pnpm
cache-dependency-path: plugin-server/pnpm-lock.yaml

- name: Install package.json dependencies with pnpm
if: needs.changes.outputs.plugin-server == 'true'
run: cd plugin-server && pnpm i

- name: Wait for Clickhouse, Redis & Kafka
if: needs.changes.outputs.plugin-server == 'true'
run: |
docker compose -f docker-compose.dev.yml up kafka redis clickhouse -d --wait
bin/check_kafka_clickhouse_up
- name: Set up databases
if: needs.changes.outputs.plugin-server == 'true'
env:
TEST: 'true'
SECRET_KEY: 'abcdef' # unsafe - for testing only
DATABASE_URL: 'postgres://posthog:posthog@localhost:5432/posthog'
run: cd plugin-server && pnpm setup:test

- name: Test with Jest
if: needs.changes.outputs.plugin-server == 'true'
env:
# Below DB name has `test_` prepended, as that's how Django (ran above) creates the test DB
DATABASE_URL: 'postgres://posthog:posthog@localhost:5432/test_posthog'
Expand Down
3 changes: 1 addition & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@
"WORKER_CONCURRENCY": "2",
"OBJECT_STORAGE_ENABLED": "True",
"HOG_HOOK_URL": "http://localhost:3300/hoghook",
"CDP_ASYNC_FUNCTIONS_RUSTY_HOOK_TEAMS": "",
"CDP_CYCLOTRON_ENABLED_TEAMS": "*"
"CDP_ASYNC_FUNCTIONS_RUSTY_HOOK_TEAMS": ""
},
"presentation": {
"group": "main"
Expand Down
6 changes: 0 additions & 6 deletions bin/migrate
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
#!/bin/bash
set -e
SCRIPT_DIR=$(dirname "$(readlink -f "$0")")

# NOTE when running in docker, rust might not exist so we need to check for it
if [ -d "$SCRIPT_DIR/../rust" ]; then
bash $SCRIPT_DIR/../rust/bin/migrate-cyclotron
fi

python manage.py migrate
python manage.py migrate_clickhouse
Expand Down
2 changes: 1 addition & 1 deletion bin/start-cyclotron
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export RUST_LOG=${DEBUG:-debug}
SQLX_QUERY_LEVEL=${SQLX_QUERY_LEVEL:-warn}
export RUST_LOG=$RUST_LOG,sqlx::query=$SQLX_QUERY_LEVEL

export DATABASE_URL=${CYCLOTRON_DATABASE_URL:-postgres://posthog:posthog@localhost:5432/cyclotron}
export DATABASE_URL=${DATABASE_URL:-postgres://posthog:posthog@localhost:5432/posthog}
export ALLOW_INTERNAL_IPS=${ALLOW_INTERNAL_IPS:-true}

./target/debug/cyclotron-fetch &
Expand Down
3 changes: 1 addition & 2 deletions plugin-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
"prettier:check": "prettier --check .",
"prepublishOnly": "pnpm build",
"setup:dev:clickhouse": "cd .. && DEBUG=1 python manage.py migrate_clickhouse",
"setup:test": "cd .. && TEST=1 python manage.py setup_test_environment && cd plugin-server && pnpm run setup:test:cyclotron",
"setup:test:cyclotron": "CYCLOTRON_DATABASE_NAME=test_cyclotron ../rust/bin/migrate-cyclotron",
"setup:test": "cd .. && TEST=1 python manage.py setup_test_environment",
"services:start": "cd .. && docker compose -f docker-compose.dev.yml up",
"services:stop": "cd .. && docker compose -f docker-compose.dev.yml down",
"services:clean": "cd .. && docker compose -f docker-compose.dev.yml rm -v",
Expand Down
14 changes: 3 additions & 11 deletions plugin-server/src/cdp/cdp-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { HogExecutor } from './hog-executor'
import { HogFunctionManager } from './hog-function-manager'
import { HogWatcher, HogWatcherState } from './hog-watcher'
import { HogFunctionInvocationResult, HogFunctionType, LogEntry } from './types'
import { createInvocation, queueBlobToString } from './utils'
import { createInvocation } from './utils'

export class CdpApi {
private hogExecutor: HogExecutor
Expand Down Expand Up @@ -144,19 +144,11 @@ export class CdpApi {
if (invocation.queue === 'fetch') {
if (mock_async_functions) {
// Add the state, simulating what executeAsyncResponse would do

// Re-parse the fetch args for the logging
const fetchArgs = {
...invocation.queueParameters,
body: queueBlobToString(invocation.queueBlob),
}

response = {
invocation: {
...invocation,
queue: 'hog',
queueParameters: { response: { status: 200 } },
queueBlob: Buffer.from('{}'),
queueParameters: { response: { status: 200, body: {} } },
},
finished: false,
logs: [
Expand All @@ -168,7 +160,7 @@ export class CdpApi {
{
level: 'info',
timestamp: DateTime.now(),
message: `fetch(${JSON.stringify(fetchArgs, null, 2)})`,
message: `fetch(${JSON.stringify(invocation.queueParameters, null, 2)})`,
},
],
}
Expand Down
Loading

0 comments on commit 937b012

Please sign in to comment.