-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Local development & add steps in README.md
#173
Changes from all commits
15a54a3
38338a2
d3c46ab
df380eb
ce5e324
6ed95b6
4d56b88
016c482
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,16 @@ | ||
FROM rust:1.68 AS build | ||
|
||
ARG CARGO_BUILD_MODE=release | ||
WORKDIR /tmp/ | ||
COPY Cargo.toml Cargo.lock ./ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This step caches built dependencies in a docker layer, causing a slower first time build, but faster subsequent builds. We aren't caching docker images in CI, and dev builds don't take too long so this doesn't provide much benefit. |
||
COPY storage/Cargo.toml ./storage/ | ||
COPY indexer_rule_type/Cargo.toml ./indexer_rule_type/ | ||
COPY indexer_rules_engine/Cargo.toml ./indexer_rules_engine/ | ||
COPY queryapi_coordinator/Cargo.toml ./queryapi_coordinator/ | ||
|
||
# We have to use sparse-registry cargo feature to avoid running out of RAM (version 1.68+) | ||
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse | ||
RUN /bin/bash -c "mkdir -p {queryapi_coordinator,indexer_rule_type,indexer_rules_engine,storage}/src" && \ | ||
echo 'fn main() {}' > queryapi_coordinator/src/main.rs && \ | ||
touch indexer_rule_type/src/lib.rs && \ | ||
touch indexer_rules_engine/src/lib.rs && \ | ||
touch storage/src/lib.rs && \ | ||
cargo build | ||
|
||
COPY ./ ./ | ||
|
||
RUN cargo build --release --package queryapi_coordinator --offline | ||
|
||
RUN if [ "$CARGO_BUILD_MODE" = "debug" ]; then \ | ||
cargo build --package queryapi_coordinator --offline; \ | ||
else \ | ||
cargo build --release --package queryapi_coordinator --offline; \ | ||
fi | ||
|
||
FROM ubuntu:20.04 | ||
|
||
ARG CARGO_BUILD_MODE=release | ||
RUN apt update && apt install -yy openssl ca-certificates | ||
|
||
USER nobody | ||
COPY --from=build /tmp/target/release/queryapi_coordinator /queryapi_coordinator | ||
COPY --from=build /tmp/target/$CARGO_BUILD_MODE/queryapi_coordinator /queryapi_coordinator | ||
ENTRYPOINT ["/queryapi_coordinator"] |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ metrics.startServer().catch((err) => { | |
}); | ||
|
||
// const BATCH_SIZE = 1; | ||
const STREAM_START_ID = '0'; | ||
const STREAM_SMALLEST_ID = '0'; | ||
// const STREAM_THROTTLE_MS = 250; | ||
const STREAM_HANDLER_THROTTLE_MS = 500; | ||
|
||
|
@@ -63,7 +63,7 @@ const getMessagesFromStream = async <Message extends Record<string, string>>( | |
lastId: string | null, | ||
count: number, | ||
): Promise<StreamMessages<Message> | null> => { | ||
const id = lastId ?? STREAM_START_ID; | ||
const id = lastId ?? STREAM_SMALLEST_ID; | ||
|
||
const results = await client.xRead( | ||
{ key: generateStreamKey(indexerName), id }, | ||
|
@@ -74,13 +74,17 @@ const getMessagesFromStream = async <Message extends Record<string, string>>( | |
return results?.[0].messages as StreamMessages<Message>; | ||
}; | ||
|
||
const incrementStreamId = (id: string): string => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When |
||
const [timestamp, sequenceNumber] = id.split('-'); | ||
const nextSequenceNumber = Number(sequenceNumber) + 1; | ||
return `${timestamp}-${nextSequenceNumber}`; | ||
}; | ||
|
||
const getUnprocessedMessages = async <Message extends Record<string, string>>( | ||
indexerName: string, | ||
startId: string | ||
startId: string | null | ||
): Promise<Array<StreamMessage<Message>>> => { | ||
const [timestamp, sequenceNumber] = startId.split('-'); | ||
const nextSequenceNumber = Number(sequenceNumber) + 1; | ||
const nextId = `${timestamp}-${nextSequenceNumber}`; | ||
const nextId = startId ? incrementStreamId(startId) : STREAM_SMALLEST_ID; | ||
|
||
const results = await client.xRange(generateStreamKey(indexerName), nextId, '+'); | ||
|
||
|
@@ -147,7 +151,7 @@ const processStream = async (indexerName: string): Promise<void> => { | |
|
||
metrics.EXECUTION_DURATION.labels({ indexer: indexerName }).set(endTime - startTime); | ||
|
||
const unprocessedMessages = await getUnprocessedMessages<IndexerStreamMessage>(indexerName, lastProcessedId ?? '-'); | ||
const unprocessedMessages = await getUnprocessedMessages<IndexerStreamMessage>(indexerName, lastProcessedId); | ||
metrics.UNPROCESSED_STREAM_MESSAGES.labels({ indexer: indexerName }).set(unprocessedMessages?.length ?? 0); | ||
|
||
console.log(`Success: ${indexerName}`); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default to release builds, but set to debug when building via the local Docker Compose