Module materialize.mzcompose.services.clusterd
Expand source code Browse git
# Copyright Materialize, Inc. and contributors. All rights reserved.
#
# Use of this software is governed by the Business Source License
# included in the LICENSE file at the root of this repository.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0.
from materialize.mzcompose import DEFAULT_MZ_ENVIRONMENT_ID, DEFAULT_MZ_VOLUMES
from materialize.mzcompose.service import (
Service,
ServiceConfig,
)
class Clusterd(Service):
def __init__(
self,
name: str = "clusterd",
image: str | None = None,
environment_id: str | None = None,
environment_extra: list[str] = [],
memory: str | None = None,
options: list[str] = [],
) -> None:
environment = [
"CLUSTERD_LOG_FILTER",
"MZ_SOFT_ASSERTIONS=1",
*environment_extra,
]
if not environment_id:
environment_id = DEFAULT_MZ_ENVIRONMENT_ID
environment += [f"CLUSTERD_ENVIRONMENT_ID={environment_id}"]
options = ["--scratch-directory=/scratch", *options]
config: ServiceConfig = {}
if image:
config["image"] = image
else:
config["mzbuild"] = "clusterd"
# Depending on the Docker Compose version, this may either work or be
# ignored with a warning. Unfortunately no portable way of setting the
# memory limit is known.
if memory:
config["deploy"] = {"resources": {"limits": {"memory": memory}}}
config.update(
{
"command": options,
"ports": [2100, 2101, 6878],
"environment": environment,
"volumes": DEFAULT_MZ_VOLUMES,
}
)
super().__init__(name=name, config=config)
Classes
class Clusterd (name: str = 'clusterd', image: str | None = None, environment_id: str | None = None, environment_extra: list[str] = [], memory: str | None = None, options: list[str] = [])
-
A Docker Compose service in a
Composition
.Attributes
name
- The name of the service.
config
- The definition of the service.
Expand source code Browse git
class Clusterd(Service): def __init__( self, name: str = "clusterd", image: str | None = None, environment_id: str | None = None, environment_extra: list[str] = [], memory: str | None = None, options: list[str] = [], ) -> None: environment = [ "CLUSTERD_LOG_FILTER", "MZ_SOFT_ASSERTIONS=1", *environment_extra, ] if not environment_id: environment_id = DEFAULT_MZ_ENVIRONMENT_ID environment += [f"CLUSTERD_ENVIRONMENT_ID={environment_id}"] options = ["--scratch-directory=/scratch", *options] config: ServiceConfig = {} if image: config["image"] = image else: config["mzbuild"] = "clusterd" # Depending on the Docker Compose version, this may either work or be # ignored with a warning. Unfortunately no portable way of setting the # memory limit is known. if memory: config["deploy"] = {"resources": {"limits": {"memory": memory}}} config.update( { "command": options, "ports": [2100, 2101, 6878], "environment": environment, "volumes": DEFAULT_MZ_VOLUMES, } ) super().__init__(name=name, config=config)
Ancestors