ankka-flow 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ankka_flow/__init__.py +40 -0
- ankka_flow/_conformance.py +93 -0
- ankka_flow/_descriptor.py +74 -0
- ankka_flow/_proto/__init__.py +0 -0
- ankka_flow/_proto/ankka/__init__.py +0 -0
- ankka_flow/_proto/ankka/flow/__init__.py +0 -0
- ankka_flow/_proto/ankka/flow/v1/__init__.py +0 -0
- ankka_flow/_proto/ankka/flow/v1/discovery_pb2.py +53 -0
- ankka_flow/_proto/ankka/flow/v1/discovery_pb2.pyi +94 -0
- ankka_flow/_proto/ankka/flow/v1/discovery_pb2_grpc.py +146 -0
- ankka_flow/_proto/ankka/flow/v1/payload_pb2.py +46 -0
- ankka_flow/_proto/ankka/flow/v1/payload_pb2.pyi +47 -0
- ankka_flow/_proto/ankka/flow/v1/payload_pb2_grpc.py +24 -0
- ankka_flow/_proto/ankka/flow/v1/streamlet_pb2.py +57 -0
- ankka_flow/_proto/ankka/flow/v1/streamlet_pb2.pyi +106 -0
- ankka_flow/_proto/ankka/flow/v1/streamlet_pb2_grpc.py +101 -0
- ankka_flow/descriptor.py +95 -0
- ankka_flow/json.py +14 -0
- ankka_flow/parameters.py +241 -0
- ankka_flow/ports.py +76 -0
- ankka_flow/py.typed +0 -0
- ankka_flow/records.py +42 -0
- ankka_flow/server.py +245 -0
- ankka_flow/streamlet.py +90 -0
- ankka_flow/testkit/__init__.py +112 -0
- ankka_flow-0.1.0.dist-info/METADATA +93 -0
- ankka_flow-0.1.0.dist-info/RECORD +29 -0
- ankka_flow-0.1.0.dist-info/WHEEL +4 -0
- ankka_flow-0.1.0.dist-info/entry_points.txt +3 -0
ankka_flow/__init__.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""ankka-flow: write streamlets in Python. The sidecar owns Kafka; this package owns the protocol."""
|
|
2
|
+
|
|
3
|
+
from . import json
|
|
4
|
+
from .descriptor import PROTOCOL_VERSION
|
|
5
|
+
from .parameters import (
|
|
6
|
+
BooleanParameter,
|
|
7
|
+
Config,
|
|
8
|
+
DoubleParameter,
|
|
9
|
+
DurationParameter,
|
|
10
|
+
IntegerParameter,
|
|
11
|
+
MemorySizeParameter,
|
|
12
|
+
Parameter,
|
|
13
|
+
StringParameter,
|
|
14
|
+
)
|
|
15
|
+
from .ports import JsonInlet, JsonOutlet
|
|
16
|
+
from .records import Batch, Emit, Record
|
|
17
|
+
from .server import serve
|
|
18
|
+
from .streamlet import Streamlet
|
|
19
|
+
|
|
20
|
+
__version__ = "0.1.0"
|
|
21
|
+
|
|
22
|
+
__all__ = [
|
|
23
|
+
"PROTOCOL_VERSION",
|
|
24
|
+
"Batch",
|
|
25
|
+
"BooleanParameter",
|
|
26
|
+
"Config",
|
|
27
|
+
"DoubleParameter",
|
|
28
|
+
"DurationParameter",
|
|
29
|
+
"Emit",
|
|
30
|
+
"IntegerParameter",
|
|
31
|
+
"JsonInlet",
|
|
32
|
+
"JsonOutlet",
|
|
33
|
+
"MemorySizeParameter",
|
|
34
|
+
"Parameter",
|
|
35
|
+
"Record",
|
|
36
|
+
"StringParameter",
|
|
37
|
+
"Streamlet",
|
|
38
|
+
"json",
|
|
39
|
+
"serve",
|
|
40
|
+
]
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"""`uv run conformance`: serve the reference streamlet and run the sidecar's conformance suite against it.
|
|
2
|
+
|
|
3
|
+
The reference is the `conformance` declaration of `proto/fixtures/declarations/conformance.md`,
|
|
4
|
+
behaving by each record's key as the protocol's conformance contract says. The suite lives in the
|
|
5
|
+
ankka-flow repository (`sidecar/src/test/.../ConformanceSuite.scala`) and needs sbt and a JDK.
|
|
6
|
+
|
|
7
|
+
Environment:
|
|
8
|
+
FLOW_PROCESS_PORT port to serve on (default 9010)
|
|
9
|
+
ANKKA_FLOW_CONFORMANCE_ONLY run only the cases whose names start with this
|
|
10
|
+
ANKKA_FLOW_BREAK break one SDK rule on purpose (`ack-first`, `keyless-empty-key`)
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import os
|
|
16
|
+
import subprocess
|
|
17
|
+
import sys
|
|
18
|
+
import time
|
|
19
|
+
from collections.abc import Iterable
|
|
20
|
+
from pathlib import Path
|
|
21
|
+
|
|
22
|
+
from ankka_flow import Batch, Emit, IntegerParameter, JsonInlet, JsonOutlet, Record, StringParameter, Streamlet, serve
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class Conformance(Streamlet):
|
|
26
|
+
"""The reference streamlet every SDK ships for the conformance suite."""
|
|
27
|
+
|
|
28
|
+
name = "conformance"
|
|
29
|
+
description = "The conformance reference streamlet."
|
|
30
|
+
inlet = JsonInlet("in", schema_name="conformance.v1")
|
|
31
|
+
side = JsonInlet("side", schema_name="conformance-side.v1")
|
|
32
|
+
out = JsonOutlet("out", schema_name="conformance.v1")
|
|
33
|
+
other = JsonOutlet("other", schema_name="conformance-other.v1")
|
|
34
|
+
mode = StringParameter("mode", default="echo", description="Unused by the suite; proves a string parameter arrives.")
|
|
35
|
+
factor = IntegerParameter("factor", default=1, description="How many times the multiply key emits.")
|
|
36
|
+
|
|
37
|
+
def process(self, batch: Batch) -> Iterable[Emit]:
|
|
38
|
+
for record in batch:
|
|
39
|
+
key = (record.key or b"").decode()
|
|
40
|
+
if key == "echo":
|
|
41
|
+
yield self.out.emit(record)
|
|
42
|
+
elif key == "fan":
|
|
43
|
+
yield self.out.emit(record)
|
|
44
|
+
yield self.other.emit(record)
|
|
45
|
+
elif key == "skip":
|
|
46
|
+
continue
|
|
47
|
+
elif key == "fail":
|
|
48
|
+
raise RuntimeError("the record said fail")
|
|
49
|
+
elif key == "late":
|
|
50
|
+
time.sleep(0.3)
|
|
51
|
+
yield self.out.emit(record)
|
|
52
|
+
elif key == "rogue-outlet":
|
|
53
|
+
yield Emit("nope", record)
|
|
54
|
+
elif key == "multiply":
|
|
55
|
+
for i in range(1, self.config[self.factor] + 1):
|
|
56
|
+
yield self.out.emit(record, headers=[*record.headers, ("n", str(i).encode())])
|
|
57
|
+
elif key == "unkeyed":
|
|
58
|
+
yield self.out.emit(record, key=None)
|
|
59
|
+
elif key == "header-echo":
|
|
60
|
+
yield self.out.emit(record, headers=list(reversed(record.headers)))
|
|
61
|
+
else:
|
|
62
|
+
yield self.out.emit(record)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def reference_streamlet() -> Conformance:
|
|
66
|
+
return Conformance()
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def _repo_root() -> Path:
|
|
70
|
+
here = Path(__file__).resolve()
|
|
71
|
+
for parent in here.parents:
|
|
72
|
+
if (parent / "build.sbt").exists() and (parent / "protocol").is_dir():
|
|
73
|
+
return parent
|
|
74
|
+
raise SystemExit("conformance: run from inside the ankka-flow repository (the suite is its sbt project)")
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def main() -> int:
|
|
78
|
+
port = int(os.environ.get("FLOW_PROCESS_PORT", "9010"))
|
|
79
|
+
server = serve(reference_streamlet(), port=port, block=False)
|
|
80
|
+
try:
|
|
81
|
+
cmd = ["sbt", "-batch", f"-Dflow.conformance.target=127.0.0.1:{port}", "-Dflow.cluster.tests=off"]
|
|
82
|
+
only = os.environ.get("ANKKA_FLOW_CONFORMANCE_ONLY")
|
|
83
|
+
if only:
|
|
84
|
+
cmd.append(f"-Dflow.conformance.only={only}")
|
|
85
|
+
cmd.append("sidecar/testOnly *ConformanceSuite")
|
|
86
|
+
print(f"conformance: serving the Python reference on 127.0.0.1:{port}; running {' '.join(cmd)}", flush=True)
|
|
87
|
+
return subprocess.call(cmd, cwd=_repo_root())
|
|
88
|
+
finally:
|
|
89
|
+
server.stop()
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
if __name__ == "__main__":
|
|
93
|
+
sys.exit(main())
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"""`uv run descriptor`: write flow/descriptor.json from the project's streamlet.
|
|
2
|
+
|
|
3
|
+
The streamlet is `module:attr`, from $FLOW_STREAMLET or `[tool.ankka-flow] streamlet` in
|
|
4
|
+
pyproject.toml. `--check` exits 1 when the file on disk differs.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import argparse
|
|
10
|
+
import importlib
|
|
11
|
+
import os
|
|
12
|
+
import pathlib
|
|
13
|
+
import sys
|
|
14
|
+
import tomllib
|
|
15
|
+
|
|
16
|
+
from .descriptor import spec_for, validate, write
|
|
17
|
+
from .streamlet import Streamlet
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _reference(root: pathlib.Path) -> str:
|
|
21
|
+
ref = os.environ.get("FLOW_STREAMLET")
|
|
22
|
+
if ref:
|
|
23
|
+
return ref
|
|
24
|
+
pyproject = root / "pyproject.toml"
|
|
25
|
+
if pyproject.exists():
|
|
26
|
+
table = tomllib.loads(pyproject.read_text()).get("tool", {}).get("ankka-flow", {})
|
|
27
|
+
if isinstance(table, dict) and isinstance(table.get("streamlet"), str):
|
|
28
|
+
return str(table["streamlet"])
|
|
29
|
+
raise SystemExit(
|
|
30
|
+
"no streamlet: set FLOW_STREAMLET=module:Class or [tool.ankka-flow] streamlet in pyproject.toml"
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def load(ref: str) -> type[Streamlet]:
|
|
35
|
+
module, _, attr = ref.partition(":")
|
|
36
|
+
if not attr:
|
|
37
|
+
raise SystemExit(f"'{ref}' is not module:attr")
|
|
38
|
+
obj = getattr(importlib.import_module(module), attr)
|
|
39
|
+
cls = obj if isinstance(obj, type) else type(obj)
|
|
40
|
+
if not issubclass(cls, Streamlet):
|
|
41
|
+
raise SystemExit(f"{ref} is not a Streamlet")
|
|
42
|
+
return cls
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def main(argv: list[str] | None = None) -> int:
|
|
46
|
+
parser = argparse.ArgumentParser(prog="descriptor", description=__doc__)
|
|
47
|
+
parser.add_argument("--out", default="flow/descriptor.json")
|
|
48
|
+
parser.add_argument("--check", action="store_true", help="exit 1 if the file differs")
|
|
49
|
+
args = parser.parse_args(argv)
|
|
50
|
+
root = pathlib.Path.cwd()
|
|
51
|
+
if (root / "src").is_dir():
|
|
52
|
+
sys.path.insert(0, str(root / "src"))
|
|
53
|
+
spec = spec_for(load(_reference(root)))
|
|
54
|
+
problems = validate(spec)
|
|
55
|
+
if problems:
|
|
56
|
+
for p in problems:
|
|
57
|
+
print(f"descriptor: {p}", file=sys.stderr)
|
|
58
|
+
return 1
|
|
59
|
+
text = write(spec)
|
|
60
|
+
out = pathlib.Path(args.out)
|
|
61
|
+
if args.check:
|
|
62
|
+
if not out.exists() or out.read_text(encoding="utf-8") != text:
|
|
63
|
+
print(f"{out} is out of date; run `uv run descriptor`", file=sys.stderr)
|
|
64
|
+
return 1
|
|
65
|
+
print(f"{out} is up to date")
|
|
66
|
+
return 0
|
|
67
|
+
out.parent.mkdir(parents=True, exist_ok=True)
|
|
68
|
+
out.write_text(text, encoding="utf-8")
|
|
69
|
+
print(f"wrote {out}")
|
|
70
|
+
return 0
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
if __name__ == "__main__":
|
|
74
|
+
sys.exit(main())
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
|
+
# NO CHECKED-IN PROTOBUF GENCODE
|
|
4
|
+
# source: ankka/flow/v1/discovery.proto
|
|
5
|
+
# Protobuf Python Version: 7.35.1
|
|
6
|
+
"""Generated protocol buffer code."""
|
|
7
|
+
from google.protobuf import descriptor as _descriptor
|
|
8
|
+
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
9
|
+
from google.protobuf import runtime_version as _runtime_version
|
|
10
|
+
from google.protobuf import symbol_database as _symbol_database
|
|
11
|
+
from google.protobuf.internal import builder as _builder
|
|
12
|
+
_runtime_version.ValidateProtobufRuntimeVersion(
|
|
13
|
+
_runtime_version.Domain.PUBLIC,
|
|
14
|
+
7,
|
|
15
|
+
35,
|
|
16
|
+
1,
|
|
17
|
+
'',
|
|
18
|
+
'ankka/flow/v1/discovery.proto'
|
|
19
|
+
)
|
|
20
|
+
# @@protoc_insertion_point(imports)
|
|
21
|
+
|
|
22
|
+
_sym_db = _symbol_database.Default()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
from ankka_flow._proto.ankka.flow.v1 import payload_pb2 as ankka_dot_flow_dot_v1_dot_payload__pb2
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1d\x61nkka/flow/v1/discovery.proto\x12\rankka.flow.v1\x1a\x1b\x61nkka/flow/v1/payload.proto\"@\n\x0bSidecarInfo\x12\x18\n\x10protocol_version\x18\x01 \x01(\t\x12\x17\n\x0fsidecar_version\x18\x02 \x01(\t\"|\n\x04Spec\x12\x18\n\x10protocol_version\x18\x01 \x01(\t\x12#\n\x03sdk\x18\x02 \x01(\x0b\x32\x16.ankka.flow.v1.SdkInfo\x12\x35\n\tstreamlet\x18\x03 \x01(\x0b\x32\".ankka.flow.v1.StreamletDescriptor\"(\n\x07SdkInfo\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0f\n\x07version\x18\x02 \x01(\t\"\xbe\x01\n\x13StreamletDescriptor\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x02 \x01(\t\x12#\n\x06inlets\x18\x03 \x03(\x0b\x32\x13.ankka.flow.v1.Port\x12$\n\x07outlets\x18\x04 \x03(\x0b\x32\x13.ankka.flow.v1.Port\x12\x39\n\x11\x63onfig_parameters\x18\x05 \x03(\x0b\x32\x1e.ankka.flow.v1.ConfigParameter\"?\n\x04Port\x12\x0c\n\x04name\x18\x01 \x01(\t\x12)\n\x08\x63ontract\x18\x02 \x01(\x0b\x32\x17.ankka.flow.v1.Contract\"D\n\x08\x43ontract\x12\x0e\n\x06\x66ormat\x18\x01 \x01(\t\x12\x13\n\x0bschema_name\x18\x02 \x01(\t\x12\x13\n\x0b\x66ingerprint\x18\x03 \x01(\t\"s\n\x0f\x43onfigParameter\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x02 \x01(\t\x12\'\n\x04type\x18\x03 \x01(\x0e\x32\x19.ankka.flow.v1.ConfigType\x12\x15\n\rdefault_value\x18\x04 \x01(\t*]\n\nConfigType\x12\n\n\x06STRING\x10\x00\x12\x0b\n\x07INTEGER\x10\x01\x12\n\n\x06\x44OUBLE\x10\x02\x12\x0b\n\x07\x42OOLEAN\x10\x03\x12\x0c\n\x08\x44URATION\x10\x04\x12\x0f\n\x0bMEMORY_SIZE\x10\x05\x32\x86\x01\n\tDiscovery\x12;\n\x08\x44iscover\x12\x1a.ankka.flow.v1.SidecarInfo\x1a\x13.ankka.flow.v1.Spec\x12<\n\x0bReportError\x12\x17.ankka.flow.v1.Problems\x1a\x14.ankka.flow.v1.Emptyb\x06proto3')
|
|
29
|
+
|
|
30
|
+
_globals = globals()
|
|
31
|
+
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
|
32
|
+
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'ankka.flow.v1.discovery_pb2', _globals)
|
|
33
|
+
if not _descriptor._USE_C_DESCRIPTORS:
|
|
34
|
+
DESCRIPTOR._loaded_options = None
|
|
35
|
+
_globals['_CONFIGTYPE']._serialized_start=756
|
|
36
|
+
_globals['_CONFIGTYPE']._serialized_end=849
|
|
37
|
+
_globals['_SIDECARINFO']._serialized_start=77
|
|
38
|
+
_globals['_SIDECARINFO']._serialized_end=141
|
|
39
|
+
_globals['_SPEC']._serialized_start=143
|
|
40
|
+
_globals['_SPEC']._serialized_end=267
|
|
41
|
+
_globals['_SDKINFO']._serialized_start=269
|
|
42
|
+
_globals['_SDKINFO']._serialized_end=309
|
|
43
|
+
_globals['_STREAMLETDESCRIPTOR']._serialized_start=312
|
|
44
|
+
_globals['_STREAMLETDESCRIPTOR']._serialized_end=502
|
|
45
|
+
_globals['_PORT']._serialized_start=504
|
|
46
|
+
_globals['_PORT']._serialized_end=567
|
|
47
|
+
_globals['_CONTRACT']._serialized_start=569
|
|
48
|
+
_globals['_CONTRACT']._serialized_end=637
|
|
49
|
+
_globals['_CONFIGPARAMETER']._serialized_start=639
|
|
50
|
+
_globals['_CONFIGPARAMETER']._serialized_end=754
|
|
51
|
+
_globals['_DISCOVERY']._serialized_start=852
|
|
52
|
+
_globals['_DISCOVERY']._serialized_end=986
|
|
53
|
+
# @@protoc_insertion_point(module_scope)
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
from ankka_flow._proto.ankka.flow.v1 import payload_pb2 as _payload_pb2
|
|
2
|
+
from google.protobuf.internal import containers as _containers
|
|
3
|
+
from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper
|
|
4
|
+
from google.protobuf import descriptor as _descriptor
|
|
5
|
+
from google.protobuf import message as _message
|
|
6
|
+
from collections.abc import Iterable as _Iterable, Mapping as _Mapping
|
|
7
|
+
from typing import ClassVar as _ClassVar, Optional as _Optional, Union as _Union
|
|
8
|
+
|
|
9
|
+
DESCRIPTOR: _descriptor.FileDescriptor
|
|
10
|
+
|
|
11
|
+
class ConfigType(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
|
|
12
|
+
__slots__ = ()
|
|
13
|
+
STRING: _ClassVar[ConfigType]
|
|
14
|
+
INTEGER: _ClassVar[ConfigType]
|
|
15
|
+
DOUBLE: _ClassVar[ConfigType]
|
|
16
|
+
BOOLEAN: _ClassVar[ConfigType]
|
|
17
|
+
DURATION: _ClassVar[ConfigType]
|
|
18
|
+
MEMORY_SIZE: _ClassVar[ConfigType]
|
|
19
|
+
STRING: ConfigType
|
|
20
|
+
INTEGER: ConfigType
|
|
21
|
+
DOUBLE: ConfigType
|
|
22
|
+
BOOLEAN: ConfigType
|
|
23
|
+
DURATION: ConfigType
|
|
24
|
+
MEMORY_SIZE: ConfigType
|
|
25
|
+
|
|
26
|
+
class SidecarInfo(_message.Message):
|
|
27
|
+
__slots__ = ("protocol_version", "sidecar_version")
|
|
28
|
+
PROTOCOL_VERSION_FIELD_NUMBER: _ClassVar[int]
|
|
29
|
+
SIDECAR_VERSION_FIELD_NUMBER: _ClassVar[int]
|
|
30
|
+
protocol_version: str
|
|
31
|
+
sidecar_version: str
|
|
32
|
+
def __init__(self, protocol_version: _Optional[str] = ..., sidecar_version: _Optional[str] = ...) -> None: ...
|
|
33
|
+
|
|
34
|
+
class Spec(_message.Message):
|
|
35
|
+
__slots__ = ("protocol_version", "sdk", "streamlet")
|
|
36
|
+
PROTOCOL_VERSION_FIELD_NUMBER: _ClassVar[int]
|
|
37
|
+
SDK_FIELD_NUMBER: _ClassVar[int]
|
|
38
|
+
STREAMLET_FIELD_NUMBER: _ClassVar[int]
|
|
39
|
+
protocol_version: str
|
|
40
|
+
sdk: SdkInfo
|
|
41
|
+
streamlet: StreamletDescriptor
|
|
42
|
+
def __init__(self, protocol_version: _Optional[str] = ..., sdk: _Optional[_Union[SdkInfo, _Mapping]] = ..., streamlet: _Optional[_Union[StreamletDescriptor, _Mapping]] = ...) -> None: ...
|
|
43
|
+
|
|
44
|
+
class SdkInfo(_message.Message):
|
|
45
|
+
__slots__ = ("name", "version")
|
|
46
|
+
NAME_FIELD_NUMBER: _ClassVar[int]
|
|
47
|
+
VERSION_FIELD_NUMBER: _ClassVar[int]
|
|
48
|
+
name: str
|
|
49
|
+
version: str
|
|
50
|
+
def __init__(self, name: _Optional[str] = ..., version: _Optional[str] = ...) -> None: ...
|
|
51
|
+
|
|
52
|
+
class StreamletDescriptor(_message.Message):
|
|
53
|
+
__slots__ = ("name", "description", "inlets", "outlets", "config_parameters")
|
|
54
|
+
NAME_FIELD_NUMBER: _ClassVar[int]
|
|
55
|
+
DESCRIPTION_FIELD_NUMBER: _ClassVar[int]
|
|
56
|
+
INLETS_FIELD_NUMBER: _ClassVar[int]
|
|
57
|
+
OUTLETS_FIELD_NUMBER: _ClassVar[int]
|
|
58
|
+
CONFIG_PARAMETERS_FIELD_NUMBER: _ClassVar[int]
|
|
59
|
+
name: str
|
|
60
|
+
description: str
|
|
61
|
+
inlets: _containers.RepeatedCompositeFieldContainer[Port]
|
|
62
|
+
outlets: _containers.RepeatedCompositeFieldContainer[Port]
|
|
63
|
+
config_parameters: _containers.RepeatedCompositeFieldContainer[ConfigParameter]
|
|
64
|
+
def __init__(self, name: _Optional[str] = ..., description: _Optional[str] = ..., inlets: _Optional[_Iterable[_Union[Port, _Mapping]]] = ..., outlets: _Optional[_Iterable[_Union[Port, _Mapping]]] = ..., config_parameters: _Optional[_Iterable[_Union[ConfigParameter, _Mapping]]] = ...) -> None: ...
|
|
65
|
+
|
|
66
|
+
class Port(_message.Message):
|
|
67
|
+
__slots__ = ("name", "contract")
|
|
68
|
+
NAME_FIELD_NUMBER: _ClassVar[int]
|
|
69
|
+
CONTRACT_FIELD_NUMBER: _ClassVar[int]
|
|
70
|
+
name: str
|
|
71
|
+
contract: Contract
|
|
72
|
+
def __init__(self, name: _Optional[str] = ..., contract: _Optional[_Union[Contract, _Mapping]] = ...) -> None: ...
|
|
73
|
+
|
|
74
|
+
class Contract(_message.Message):
|
|
75
|
+
__slots__ = ("format", "schema_name", "fingerprint")
|
|
76
|
+
FORMAT_FIELD_NUMBER: _ClassVar[int]
|
|
77
|
+
SCHEMA_NAME_FIELD_NUMBER: _ClassVar[int]
|
|
78
|
+
FINGERPRINT_FIELD_NUMBER: _ClassVar[int]
|
|
79
|
+
format: str
|
|
80
|
+
schema_name: str
|
|
81
|
+
fingerprint: str
|
|
82
|
+
def __init__(self, format: _Optional[str] = ..., schema_name: _Optional[str] = ..., fingerprint: _Optional[str] = ...) -> None: ...
|
|
83
|
+
|
|
84
|
+
class ConfigParameter(_message.Message):
|
|
85
|
+
__slots__ = ("key", "description", "type", "default_value")
|
|
86
|
+
KEY_FIELD_NUMBER: _ClassVar[int]
|
|
87
|
+
DESCRIPTION_FIELD_NUMBER: _ClassVar[int]
|
|
88
|
+
TYPE_FIELD_NUMBER: _ClassVar[int]
|
|
89
|
+
DEFAULT_VALUE_FIELD_NUMBER: _ClassVar[int]
|
|
90
|
+
key: str
|
|
91
|
+
description: str
|
|
92
|
+
type: ConfigType
|
|
93
|
+
default_value: str
|
|
94
|
+
def __init__(self, key: _Optional[str] = ..., description: _Optional[str] = ..., type: _Optional[_Union[ConfigType, str]] = ..., default_value: _Optional[str] = ...) -> None: ...
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
|
|
2
|
+
"""Client and server classes corresponding to protobuf-defined services."""
|
|
3
|
+
import grpc
|
|
4
|
+
import warnings
|
|
5
|
+
|
|
6
|
+
from ankka_flow._proto.ankka.flow.v1 import discovery_pb2 as ankka_dot_flow_dot_v1_dot_discovery__pb2
|
|
7
|
+
from ankka_flow._proto.ankka.flow.v1 import payload_pb2 as ankka_dot_flow_dot_v1_dot_payload__pb2
|
|
8
|
+
|
|
9
|
+
GRPC_GENERATED_VERSION = '1.84.0'
|
|
10
|
+
GRPC_VERSION = grpc.__version__
|
|
11
|
+
_version_not_supported = False
|
|
12
|
+
|
|
13
|
+
try:
|
|
14
|
+
from grpc._utilities import first_version_is_lower
|
|
15
|
+
_version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
|
|
16
|
+
except ImportError:
|
|
17
|
+
_version_not_supported = True
|
|
18
|
+
|
|
19
|
+
if _version_not_supported:
|
|
20
|
+
raise RuntimeError(
|
|
21
|
+
f'The grpc package installed is at version {GRPC_VERSION},'
|
|
22
|
+
+ ' but the generated code in ankka/flow/v1/discovery_pb2_grpc.py depends on'
|
|
23
|
+
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
|
|
24
|
+
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
|
|
25
|
+
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class DiscoveryStub:
|
|
30
|
+
"""Implemented by the developer's process on 127.0.0.1:$FLOW_PROCESS_PORT; dialled by the sidecar.
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
def __init__(self, channel):
|
|
34
|
+
"""Constructor.
|
|
35
|
+
|
|
36
|
+
Args:
|
|
37
|
+
channel: A grpc.Channel.
|
|
38
|
+
"""
|
|
39
|
+
self.Discover = channel.unary_unary(
|
|
40
|
+
'/ankka.flow.v1.Discovery/Discover',
|
|
41
|
+
request_serializer=ankka_dot_flow_dot_v1_dot_discovery__pb2.SidecarInfo.SerializeToString,
|
|
42
|
+
response_deserializer=ankka_dot_flow_dot_v1_dot_discovery__pb2.Spec.FromString,
|
|
43
|
+
_registered_method=True)
|
|
44
|
+
self.ReportError = channel.unary_unary(
|
|
45
|
+
'/ankka.flow.v1.Discovery/ReportError',
|
|
46
|
+
request_serializer=ankka_dot_flow_dot_v1_dot_payload__pb2.Problems.SerializeToString,
|
|
47
|
+
response_deserializer=ankka_dot_flow_dot_v1_dot_payload__pb2.Empty.FromString,
|
|
48
|
+
_registered_method=True)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class DiscoveryServicer:
|
|
52
|
+
"""Implemented by the developer's process on 127.0.0.1:$FLOW_PROCESS_PORT; dialled by the sidecar.
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
def Discover(self, request, context):
|
|
56
|
+
"""The process describes itself. The sidecar compares the answer with the deployed descriptor.
|
|
57
|
+
"""
|
|
58
|
+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
59
|
+
context.set_details('Method not implemented!')
|
|
60
|
+
raise NotImplementedError('Method not implemented!')
|
|
61
|
+
|
|
62
|
+
def ReportError(self, request, context):
|
|
63
|
+
"""The sidecar's refusal, so the problems appear in the process's own log before it exits.
|
|
64
|
+
"""
|
|
65
|
+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
66
|
+
context.set_details('Method not implemented!')
|
|
67
|
+
raise NotImplementedError('Method not implemented!')
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def add_DiscoveryServicer_to_server(servicer, server):
|
|
71
|
+
rpc_method_handlers = {
|
|
72
|
+
'Discover': grpc.unary_unary_rpc_method_handler(
|
|
73
|
+
servicer.Discover,
|
|
74
|
+
request_deserializer=ankka_dot_flow_dot_v1_dot_discovery__pb2.SidecarInfo.FromString,
|
|
75
|
+
response_serializer=ankka_dot_flow_dot_v1_dot_discovery__pb2.Spec.SerializeToString,
|
|
76
|
+
),
|
|
77
|
+
'ReportError': grpc.unary_unary_rpc_method_handler(
|
|
78
|
+
servicer.ReportError,
|
|
79
|
+
request_deserializer=ankka_dot_flow_dot_v1_dot_payload__pb2.Problems.FromString,
|
|
80
|
+
response_serializer=ankka_dot_flow_dot_v1_dot_payload__pb2.Empty.SerializeToString,
|
|
81
|
+
),
|
|
82
|
+
}
|
|
83
|
+
generic_handler = grpc.method_handlers_generic_handler(
|
|
84
|
+
'ankka.flow.v1.Discovery', rpc_method_handlers)
|
|
85
|
+
server.add_generic_rpc_handlers((generic_handler,))
|
|
86
|
+
server.add_registered_method_handlers('ankka.flow.v1.Discovery', rpc_method_handlers)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
# This class is part of an EXPERIMENTAL API.
|
|
90
|
+
class Discovery:
|
|
91
|
+
"""Implemented by the developer's process on 127.0.0.1:$FLOW_PROCESS_PORT; dialled by the sidecar.
|
|
92
|
+
"""
|
|
93
|
+
|
|
94
|
+
@staticmethod
|
|
95
|
+
def Discover(request,
|
|
96
|
+
target,
|
|
97
|
+
options=(),
|
|
98
|
+
channel_credentials=None,
|
|
99
|
+
call_credentials=None,
|
|
100
|
+
insecure=False,
|
|
101
|
+
compression=None,
|
|
102
|
+
wait_for_ready=None,
|
|
103
|
+
timeout=None,
|
|
104
|
+
metadata=None):
|
|
105
|
+
return grpc.experimental.unary_unary(
|
|
106
|
+
request,
|
|
107
|
+
target,
|
|
108
|
+
'/ankka.flow.v1.Discovery/Discover',
|
|
109
|
+
ankka_dot_flow_dot_v1_dot_discovery__pb2.SidecarInfo.SerializeToString,
|
|
110
|
+
ankka_dot_flow_dot_v1_dot_discovery__pb2.Spec.FromString,
|
|
111
|
+
options,
|
|
112
|
+
channel_credentials,
|
|
113
|
+
insecure,
|
|
114
|
+
call_credentials,
|
|
115
|
+
compression,
|
|
116
|
+
wait_for_ready,
|
|
117
|
+
timeout,
|
|
118
|
+
metadata,
|
|
119
|
+
_registered_method=True)
|
|
120
|
+
|
|
121
|
+
@staticmethod
|
|
122
|
+
def ReportError(request,
|
|
123
|
+
target,
|
|
124
|
+
options=(),
|
|
125
|
+
channel_credentials=None,
|
|
126
|
+
call_credentials=None,
|
|
127
|
+
insecure=False,
|
|
128
|
+
compression=None,
|
|
129
|
+
wait_for_ready=None,
|
|
130
|
+
timeout=None,
|
|
131
|
+
metadata=None):
|
|
132
|
+
return grpc.experimental.unary_unary(
|
|
133
|
+
request,
|
|
134
|
+
target,
|
|
135
|
+
'/ankka.flow.v1.Discovery/ReportError',
|
|
136
|
+
ankka_dot_flow_dot_v1_dot_payload__pb2.Problems.SerializeToString,
|
|
137
|
+
ankka_dot_flow_dot_v1_dot_payload__pb2.Empty.FromString,
|
|
138
|
+
options,
|
|
139
|
+
channel_credentials,
|
|
140
|
+
insecure,
|
|
141
|
+
call_credentials,
|
|
142
|
+
compression,
|
|
143
|
+
wait_for_ready,
|
|
144
|
+
timeout,
|
|
145
|
+
metadata,
|
|
146
|
+
_registered_method=True)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
|
+
# NO CHECKED-IN PROTOBUF GENCODE
|
|
4
|
+
# source: ankka/flow/v1/payload.proto
|
|
5
|
+
# Protobuf Python Version: 7.35.1
|
|
6
|
+
"""Generated protocol buffer code."""
|
|
7
|
+
from google.protobuf import descriptor as _descriptor
|
|
8
|
+
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
9
|
+
from google.protobuf import runtime_version as _runtime_version
|
|
10
|
+
from google.protobuf import symbol_database as _symbol_database
|
|
11
|
+
from google.protobuf.internal import builder as _builder
|
|
12
|
+
_runtime_version.ValidateProtobufRuntimeVersion(
|
|
13
|
+
_runtime_version.Domain.PUBLIC,
|
|
14
|
+
7,
|
|
15
|
+
35,
|
|
16
|
+
1,
|
|
17
|
+
'',
|
|
18
|
+
'ankka/flow/v1/payload.proto'
|
|
19
|
+
)
|
|
20
|
+
# @@protoc_insertion_point(imports)
|
|
21
|
+
|
|
22
|
+
_sym_db = _symbol_database.Default()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1b\x61nkka/flow/v1/payload.proto\x12\rankka.flow.v1\"Y\n\x06Record\x12\x10\n\x03key\x18\x01 \x01(\x0cH\x00\x88\x01\x01\x12&\n\x07headers\x18\x02 \x03(\x0b\x32\x15.ankka.flow.v1.Header\x12\r\n\x05value\x18\x03 \x01(\x0c\x42\x06\n\x04_key\"$\n\x06Header\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x0c\"\x18\n\x05\x45rror\x12\x0f\n\x07message\x18\x01 \x01(\t\"\x1a\n\x07Problem\x12\x0f\n\x07message\x18\x01 \x01(\t\"4\n\x08Problems\x12(\n\x08problems\x18\x01 \x03(\x0b\x32\x16.ankka.flow.v1.Problem\"\x07\n\x05\x45mptyb\x06proto3')
|
|
28
|
+
|
|
29
|
+
_globals = globals()
|
|
30
|
+
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
|
31
|
+
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'ankka.flow.v1.payload_pb2', _globals)
|
|
32
|
+
if not _descriptor._USE_C_DESCRIPTORS:
|
|
33
|
+
DESCRIPTOR._loaded_options = None
|
|
34
|
+
_globals['_RECORD']._serialized_start=46
|
|
35
|
+
_globals['_RECORD']._serialized_end=135
|
|
36
|
+
_globals['_HEADER']._serialized_start=137
|
|
37
|
+
_globals['_HEADER']._serialized_end=173
|
|
38
|
+
_globals['_ERROR']._serialized_start=175
|
|
39
|
+
_globals['_ERROR']._serialized_end=199
|
|
40
|
+
_globals['_PROBLEM']._serialized_start=201
|
|
41
|
+
_globals['_PROBLEM']._serialized_end=227
|
|
42
|
+
_globals['_PROBLEMS']._serialized_start=229
|
|
43
|
+
_globals['_PROBLEMS']._serialized_end=281
|
|
44
|
+
_globals['_EMPTY']._serialized_start=283
|
|
45
|
+
_globals['_EMPTY']._serialized_end=290
|
|
46
|
+
# @@protoc_insertion_point(module_scope)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from google.protobuf.internal import containers as _containers
|
|
2
|
+
from google.protobuf import descriptor as _descriptor
|
|
3
|
+
from google.protobuf import message as _message
|
|
4
|
+
from collections.abc import Iterable as _Iterable, Mapping as _Mapping
|
|
5
|
+
from typing import ClassVar as _ClassVar, Optional as _Optional, Union as _Union
|
|
6
|
+
|
|
7
|
+
DESCRIPTOR: _descriptor.FileDescriptor
|
|
8
|
+
|
|
9
|
+
class Record(_message.Message):
|
|
10
|
+
__slots__ = ("key", "headers", "value")
|
|
11
|
+
KEY_FIELD_NUMBER: _ClassVar[int]
|
|
12
|
+
HEADERS_FIELD_NUMBER: _ClassVar[int]
|
|
13
|
+
VALUE_FIELD_NUMBER: _ClassVar[int]
|
|
14
|
+
key: bytes
|
|
15
|
+
headers: _containers.RepeatedCompositeFieldContainer[Header]
|
|
16
|
+
value: bytes
|
|
17
|
+
def __init__(self, key: _Optional[bytes] = ..., headers: _Optional[_Iterable[_Union[Header, _Mapping]]] = ..., value: _Optional[bytes] = ...) -> None: ...
|
|
18
|
+
|
|
19
|
+
class Header(_message.Message):
|
|
20
|
+
__slots__ = ("key", "value")
|
|
21
|
+
KEY_FIELD_NUMBER: _ClassVar[int]
|
|
22
|
+
VALUE_FIELD_NUMBER: _ClassVar[int]
|
|
23
|
+
key: str
|
|
24
|
+
value: bytes
|
|
25
|
+
def __init__(self, key: _Optional[str] = ..., value: _Optional[bytes] = ...) -> None: ...
|
|
26
|
+
|
|
27
|
+
class Error(_message.Message):
|
|
28
|
+
__slots__ = ("message",)
|
|
29
|
+
MESSAGE_FIELD_NUMBER: _ClassVar[int]
|
|
30
|
+
message: str
|
|
31
|
+
def __init__(self, message: _Optional[str] = ...) -> None: ...
|
|
32
|
+
|
|
33
|
+
class Problem(_message.Message):
|
|
34
|
+
__slots__ = ("message",)
|
|
35
|
+
MESSAGE_FIELD_NUMBER: _ClassVar[int]
|
|
36
|
+
message: str
|
|
37
|
+
def __init__(self, message: _Optional[str] = ...) -> None: ...
|
|
38
|
+
|
|
39
|
+
class Problems(_message.Message):
|
|
40
|
+
__slots__ = ("problems",)
|
|
41
|
+
PROBLEMS_FIELD_NUMBER: _ClassVar[int]
|
|
42
|
+
problems: _containers.RepeatedCompositeFieldContainer[Problem]
|
|
43
|
+
def __init__(self, problems: _Optional[_Iterable[_Union[Problem, _Mapping]]] = ...) -> None: ...
|
|
44
|
+
|
|
45
|
+
class Empty(_message.Message):
|
|
46
|
+
__slots__ = ()
|
|
47
|
+
def __init__(self) -> None: ...
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
|
|
2
|
+
"""Client and server classes corresponding to protobuf-defined services."""
|
|
3
|
+
import grpc
|
|
4
|
+
import warnings
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
GRPC_GENERATED_VERSION = '1.84.0'
|
|
8
|
+
GRPC_VERSION = grpc.__version__
|
|
9
|
+
_version_not_supported = False
|
|
10
|
+
|
|
11
|
+
try:
|
|
12
|
+
from grpc._utilities import first_version_is_lower
|
|
13
|
+
_version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
|
|
14
|
+
except ImportError:
|
|
15
|
+
_version_not_supported = True
|
|
16
|
+
|
|
17
|
+
if _version_not_supported:
|
|
18
|
+
raise RuntimeError(
|
|
19
|
+
f'The grpc package installed is at version {GRPC_VERSION},'
|
|
20
|
+
+ ' but the generated code in ankka/flow/v1/payload_pb2_grpc.py depends on'
|
|
21
|
+
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
|
|
22
|
+
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
|
|
23
|
+
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
|
|
24
|
+
)
|