Skip to content

Commit

Permalink
feat: standalone module
Browse files Browse the repository at this point in the history
- we create a new module schema_registry

- we move all FastAPI related code into this new folder

- going forward, move out all SR related things into this new folder
  • Loading branch information
nosahama committed Nov 22, 2024
1 parent 60a8086 commit 609eb45
Show file tree
Hide file tree
Showing 32 changed files with 722 additions and 271 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[run]
branch = true
relative_files = true
source = src/karapace
source = src
17 changes: 3 additions & 14 deletions container/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,10 @@ services:
- kafka
ports:
- "8081:8081"
volumes:
- ./karapace.env:/opt/karapace/karapace.env
environment:
KARAPACE_ADVERTISED_HOSTNAME: karapace-registry
KARAPACE_BOOTSTRAP_URI: kafka:29092
KARAPACE_PORT: 8081
KARAPACE_HOST: 0.0.0.0
KARAPACE_CLIENT_ID: karapace
KARAPACE_GROUP_ID: karapace-registry
KARAPACE_MASTER_ELIGIBILITY: "true"
KARAPACE_TOPIC_NAME: _schemas
KARAPACE_LOG_LEVEL: WARNING
KARAPACE_COMPATIBILITY: FULL
KARAPACE_STATSD_HOST: statsd-exporter
KARAPACE_STATSD_PORT: 8125
KARAPACE_KAFKA_SCHEMA_READER_STRICT_MODE: false
KARAPACE_KAFKA_RETRIABLE_ERRORS_SILENCED: true
KARAPACE_DOTENV: /opt/karapace/karapace.env

karapace-rest:
image: ghcr.io/aiven-open/karapace:develop
Expand Down
46 changes: 46 additions & 0 deletions container/karapace.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
KARAPACE_DOTENV=/opt/karapace/karapace.env
ACCESS_LOGS_DEBUG=False
ADVERTISED_HOSTNAME=karapace-schema-registry
ADVERTISED_PORT=8081
ADVERTISED_PROTOCOL=http
BOOTSTRAP_URI=kafka:29092
CLIENT_ID=karapace-schema-registry
COMPATIBILITY=BACKWARD
CONNECTIONS_MAX_IDLE_MS=15000
CONSUMER_ENABLE_AUTO_COMMIT=True
CONSUMER_REQUEST_TIMEOUT_MS=11000
CONSUMER_REQUEST_MAX_BYTES=67108864
CONSUMER_IDLE_DISCONNECT_TIMEOUT=0
FETCH_MIN_BYTES=1
GROUP_ID=karapace-schema-registry
HOST=0.0.0.0
PORT=8081
REGISTRY_HOST=karapace-registry
REGISTRY_PORT=8081
REST_AUTHORIZATION=False
LOG_HANDLER=stdout
LOG_LEVEL=DEBUG
LOG_FORMAT=%(asctime)s [%(threadName)s] %(filename)s:%(funcName)s:%(lineno)d %(message)s
MASTER_ELIGIBILITY=True
REPLICATION_FACTOR=1
SECURITY_PROTOCOL=PLAINTEXT
SSL_CHECK_HOSTNAME=True
TOPIC_NAME=_schemas
METADATA_MAX_AGE_MS=60000
ADMIN_METADATA_MAX_AGE=5
PRODUCER_ACKS=1
PRODUCER_COUNT=5
PRODUCER_LINGER_MS=100
PRODUCER_MAX_REQUEST_SIZE=1048576
SESSION_TIMEOUT_MS=10000
KARAPACE_REST=False
KARAPACE_REGISTRY=True
NAME_STRATEGY=topic_name
NAME_STRATEGY_VALIDATION=True
MASTER_ELECTION_STRATEGY=lowest
PROTOBUF_RUNTIME_DIRECTORY=runtime
STATSD_HOST=statsd-exporter
STATSD_PORT=8125
KAFKA_SCHEMA_READER_STRICT_MODE=False
KAFKA_RETRIABLE_ERRORS_SILENCED=True
USE_PROTOBUF_FORMATTER=False
18 changes: 1 addition & 17 deletions container/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,8 @@ rest)
exec python3 -m karapace.karapace_all /opt/karapace/rest.config.json
;;
registry)
# Reexport variables for compatibility
[[ -n ${KARAPACE_REGISTRY_ADVERTISED_HOSTNAME+isset} ]] && export KARAPACE_ADVERTISED_HOSTNAME="${KARAPACE_REGISTRY_ADVERTISED_HOSTNAME}"
[[ -n ${KARAPACE_REGISTRY_BOOTSTRAP_URI+isset} ]] && export KARAPACE_BOOTSTRAP_URI="${KARAPACE_REGISTRY_BOOTSTRAP_URI}"
[[ -n ${KARAPACE_REGISTRY_HOST+isset} ]] && export KARAPACE_HOST="${KARAPACE_REGISTRY_HOST}"
[[ -n ${KARAPACE_REGISTRY_PORT+isset} ]] && export KARAPACE_PORT="${KARAPACE_REGISTRY_PORT}"
[[ -n ${KARAPACE_REGISTRY_CLIENT_ID+isset} ]] && export KARAPACE_CLIENT_ID="${KARAPACE_REGISTRY_CLIENT_ID}"
[[ -n ${KARAPACE_REGISTRY_GROUP_ID+isset} ]] && export KARAPACE_GROUP_ID="${KARAPACE_REGISTRY_GROUP_ID}"
# Map misspelled environment variables to correct spelling for backwards compatibility.
[[ -n ${KARAPACE_REGISTRY_MASTER_ELIGIBITY+isset} ]] && export KARAPACE_MASTER_ELIGIBILITY="${KARAPACE_REGISTRY_MASTER_ELIGIBITY}"
[[ -n ${KARAPACE_REGISTRY_MASTER_ELIGIBILITY+isset} ]] && export KARAPACE_MASTER_ELIGIBILITY="${KARAPACE_REGISTRY_MASTER_ELIGIBILITY}"
[[ -n ${KARAPACE_REGISTRY_TOPIC_NAME+isset} ]] && export KARAPACE_TOPIC_NAME="${KARAPACE_REGISTRY_TOPIC_NAME}"
[[ -n ${KARAPACE_REGISTRY_COMPATIBILITY+isset} ]] && export KARAPACE_COMPATIBILITY="${KARAPACE_REGISTRY_COMPATIBILITY}"
[[ -n ${KARAPACE_REGISTRY_LOG_LEVEL+isset} ]] && export KARAPACE_LOG_LEVEL="${KARAPACE_REGISTRY_LOG_LEVEL}"
export KARAPACE_REGISTRY=1
echo "{}" >/opt/karapace/registry.config.json

echo "Starting Karapace Schema Registry"
exec python3 -m karapace.karapace_all /opt/karapace/registry.config.json
exec python3 -m schema_registry
;;
*)
echo "usage: start-karapace.sh <registry|rest>"
Expand Down
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ warn_no_return = True
warn_unreachable = True
strict_equality = True

[mypy-karapace.schema_registry_apis]
[mypy-schema_registry.schema_registry_apis]
ignore_errors = True

[mypy-karapace.compatibility.jsonschema.checks]
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ dependencies = [
"zstandard",
"prometheus-client == 0.20.0",
"yarl == 1.12.1",
"opentelemetry-api == 1.28.2",
"opentelemetry-sdk == 1.28.2",
"opentelemetry-instrumentation-fastapi == 0.49b2",
"dependency-injector == 4.43.0",

# Patched dependencies
#
Expand Down
Loading

0 comments on commit 609eb45

Please sign in to comment.