manages uploads to an S3 inbox bucket.
An extensive documentation can be found here (coming soon).
We recommend using the provided Docker container.
A pre-build version is available at docker hub:
docker pull ghga/upload-controller-service:4.0.4
Or you can build the container yourself from the ./Dockerfile
:
# Execute in the repo's root dir:
docker build -t ghga/upload-controller-service:4.0.4 .
For production-ready deployment, we recommend using Kubernetes, however, for simple use cases, you could execute the service using docker on a single server:
# The entrypoint is preconfigured:
docker run -p 8080:8080 ghga/upload-controller-service:4.0.4 --help
If you prefer not to use containers, you may install the service from source:
# Execute in the repo's root dir:
pip install .
# To run the service:
ucs --help
The service requires the following configuration parameters:
-
file_upload_received_topic
(string, required): The name of the topic use to publish FileUploadReceived events.Examples:
"file-upload-received"
-
file_upload_received_collection
(string, required): The name of the collection used to store FileUploadReceived events. The value should use hyphens in place of underscores if needed.Examples:
"fileUploads"
-
file_deleted_event_topic
(string, required): Name of the topic used for events indicating that a file has been deleted.Examples:
"file-downloads"
-
file_deleted_event_type
(string, required): The type used for events indicating that a file has been deleted.Examples:
"file_deleted"
-
files_to_delete_topic
(string, required): The name of the topic for events informing about files to be deleted.Examples:
"file_deletions"
-
file_metadata_event_topic
(string, required): Name of the topic to receive new or changed metadata on files that shall be registered for uploaded.Examples:
"metadata"
-
file_metadata_event_type
(string, required): The type used for events to receive new or changed metadata on files that are expected to be uploaded.Examples:
"file_metadata_upserted"
-
upload_accepted_event_topic
(string, required): Name of the topic to receive event that indicate that an upload was by downstream services.Examples:
"internal-file-registry"
-
upload_accepted_event_type
(string, required): The type used for event that indicate that an upload was by downstream services.Examples:
"file_registered"
-
upload_rejected_event_topic
(string, required): Name of the topic used for events informing about rejection of an upload by downstream services due to validation failure.Examples:
"file-interrogation"
-
upload_rejected_event_type
(string, required): The type used for events informing about the failure of a file validation.Examples:
"file_validation_failed"
-
log_level
(string): The minimum log level to capture. Must be one of:["CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG", "TRACE"]
. Default:"INFO"
. -
service_name
(string): Default:"ucs"
. -
service_instance_id
(string, required): A string that uniquely identifies this instance across all instances of this service. A globally unique Kafka client ID will be created by concatenating the service_name and the service_instance_id.Examples:
"germany-bw-instance-001"
-
log_format
: If set, will replace JSON formatting with the specified string format. If not set, has no effect. In addition to the standard attributes, the following can also be specified: timestamp, service, instance, level, correlation_id, and details. Default:null
.-
Any of
-
string
-
null
-
Examples:
"%(timestamp)s - %(service)s - %(level)s - %(message)s"
"%(asctime)s - Severity: %(levelno)s - %(msg)s"
-
-
log_traceback
(boolean): Whether to include exception tracebacks in log messages. Default:true
. -
kafka_servers
(array, required): A list of connection strings to connect to Kafka bootstrap servers.- Items (string)
Examples:
[ "localhost:9092" ]
-
kafka_security_protocol
(string): Protocol used to communicate with brokers. Valid values are: PLAINTEXT, SSL. Must be one of:["PLAINTEXT", "SSL"]
. Default:"PLAINTEXT"
. -
kafka_ssl_cafile
(string): Certificate Authority file path containing certificates used to sign broker certificates. If a CA is not specified, the default system CA will be used if found by OpenSSL. Default:""
. -
kafka_ssl_certfile
(string): Optional filename of client certificate, as well as any CA certificates needed to establish the certificate's authenticity. Default:""
. -
kafka_ssl_keyfile
(string): Optional filename containing the client private key. Default:""
. -
kafka_ssl_password
(string, format: password): Optional password to be used for the client private key. Default:""
. -
generate_correlation_id
(boolean): A flag, which, if False, will result in an error when inbound requests don't possess a correlation ID. If True, requests without a correlation ID will be assigned a newly generated ID in the correlation ID middleware function. Default:true
.Examples:
true
false
-
kafka_max_message_size
(integer): The largest message size that can be transmitted, in bytes. Only services that have a need to send/receive larger messages should set this. Exclusive minimum:0
. Default:1048576
.Examples:
1048576
16777216
-
object_storages
(object, required): Can contain additional properties.- Additional properties: Refer to #/$defs/S3ObjectStorageNodeConfig.
-
db_connection_str
(string, format: password, required): MongoDB connection string. Might include credentials. For more information see: https://naiveskill.com/mongodb-connection-string/.Examples:
"mongodb://localhost:27017"
-
db_name
(string, required): Name of the database located on the MongoDB server.Examples:
"my-database"
-
host
(string): IP of the host. Default:"127.0.0.1"
. -
port
(integer): Port to expose the server on the specified host. Default:8080
. -
auto_reload
(boolean): A development feature. Set toTrue
to automatically reload the server upon code changes. Default:false
. -
workers
(integer): Number of workers processes to run. Default:1
. -
api_root_path
(string): Root path at which the API is reachable. This is relative to the specified host and port. Default:""
. -
openapi_url
(string): Path to get the openapi specification in JSON format. This is relative to the specified host and port. Default:"/openapi.json"
. -
docs_url
(string): Path to host the swagger documentation. This is relative to the specified host and port. Default:"/docs"
. -
cors_allowed_origins
: A list of origins that should be permitted to make cross-origin requests. By default, cross-origin requests are not allowed. You can use ['*'] to allow any origin. Default:null
.-
Any of
-
array
- Items (string)
-
null
-
Examples:
[ "https://example.org", "https://www.example.org" ]
-
-
cors_allow_credentials
: Indicate that cookies should be supported for cross-origin requests. Defaults to False. Also, cors_allowed_origins cannot be set to ['*'] for credentials to be allowed. The origins must be explicitly specified. Default:null
.-
Any of
-
boolean
-
null
-
Examples:
[ "https://example.org", "https://www.example.org" ]
-
-
cors_allowed_methods
: A list of HTTP methods that should be allowed for cross-origin requests. Defaults to ['GET']. You can use ['*'] to allow all standard methods. Default:null
.-
Any of
-
array
- Items (string)
-
null
-
Examples:
[ "*" ]
-
-
cors_allowed_headers
: A list of HTTP request headers that should be supported for cross-origin requests. Defaults to []. You can use ['*'] to allow all headers. The Accept, Accept-Language, Content-Language and Content-Type headers are always allowed for CORS requests. Default:null
.-
Any of
-
array
- Items (string)
-
null
-
Examples:
[]
-
-
S3Config
(object): S3-specific config params. Inherit your config class from this class if you need to talk to an S3 service in the backend.
Args: s3_endpoint_url (str): The URL to the S3 endpoint. s3_access_key_id (str): Part of credentials for login into the S3 service. See: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html s3_secret_access_key (str): Part of credentials for login into the S3 service. See: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html s3_session_token (Optional[str]): Optional part of credentials for login into the S3 service. See: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html aws_config_ini (Optional[Path]): Path to a config file for specifying more advanced S3 parameters. This should follow the format described here: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/configuration.html#using-a-configuration-file Defaults to None. Cannot contain additional properties.-
s3_endpoint_url
(string, required): URL to the S3 API.Examples:
"http://localhost:4566"
-
s3_access_key_id
(string, required): Part of credentials for login into the S3 service. See: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html.Examples:
"my-access-key-id"
-
s3_secret_access_key
(string, format: password, required): Part of credentials for login into the S3 service. See: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html.Examples:
"my-secret-access-key"
-
s3_session_token
: Part of credentials for login into the S3 service. See: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html. Default:null
.-
Any of
-
string, format: password
-
null
-
Examples:
"my-session-token"
-
-
aws_config_ini
: Path to a config file for specifying more advanced S3 parameters. This should follow the format described here: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/configuration.html#using-a-configuration-file. Default:null
.-
Any of
-
string, format: path
-
null
-
Examples:
"~/.aws/config"
-
-
-
S3ObjectStorageNodeConfig
(object): Configuration for one specific object storage node and one bucket in it.
The bucket is the main bucket that the service is responsible for. Cannot contain additional properties.-
bucket
(string, required) -
credentials
: Refer to #/$defs/S3Config.
-
A template YAML for configuring the service can be found at
./example-config.yaml
.
Please adapt it, rename it to .ucs.yaml
, and place it into one of the following locations:
- in the current working directory were you are execute the service (on unix:
./.ucs.yaml
) - in your home directory (on unix:
~/.ucs.yaml
)
The config yaml will be automatically parsed by the service.
Important: If you are using containers, the locations refer to paths within the container.
All parameters mentioned in the ./example-config.yaml
could also be set using environment variables or file secrets.
For naming the environment variables, just prefix the parameter name with ucs_
,
e.g. for the host
set an environment variable named ucs_host
(you may use both upper or lower cases, however, it is standard to define all env
variables in upper cases).
To using file secrets please refer to the corresponding section of the pydantic documentation.
An OpenAPI specification for this service can be found here.
This is a Python-based service following the Triple Hexagonal Architecture pattern. It uses protocol/provider pairs and dependency injection mechanisms provided by the hexkit library.
For setting up the development environment, we rely on the devcontainer feature of VS Code in combination with Docker Compose.
To use it, you have to have Docker Compose as well as VS Code with its "Remote - Containers"
extension (ms-vscode-remote.remote-containers
) installed.
Then open this repository in VS Code and run the command
Remote-Containers: Reopen in Container
from the VS Code "Command Palette".
This will give you a full-fledged, pre-configured development environment including:
- infrastructural dependencies of the service (databases, etc.)
- all relevant VS Code extensions pre-installed
- pre-configured linting and auto-formatting
- a pre-configured debugger
- automatic license-header insertion
Moreover, inside the devcontainer, a convenience commands dev_install
is available.
It installs the service with all development dependencies, installs pre-commit.
The installation is performed automatically when you build the devcontainer. However,
if you update dependencies in the ./pyproject.toml
or the
./requirements-dev.txt
, please run it again.
This repository is free to use and modify according to the Apache 2.0 License.
This README file is auto-generated, please see readme_generation.md
for details.