diff --git a/build.gradle.kts b/build.gradle.kts index 15bbe53c6ffd..977eed2b81c7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -216,6 +216,9 @@ tasks.rat { // Ignore poetry autogenerated files. "**/poetry.lock", + // Ignore Cargo lock files. + "sdks/rust/Cargo.lock", + // DuetAI training prompts "learning/prompts/**/*.md", diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index c8bcc22c9021..9867b484fd83 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -115,5 +115,9 @@ gradlePlugin { id = "org.apache.beam.vendor-java" implementationClass = "org.apache.beam.gradle.VendorJavaPlugin" } + create("beamRust") { + id = "org.apache.beam.rust" + implementationClass = "org.apache.beam.gradle.rust.BeamRustPlugin" + } } } diff --git a/buildSrc/src/main/groovy/org/apache/beam/gradle/rust/BeamRustPlugin.groovy b/buildSrc/src/main/groovy/org/apache/beam/gradle/rust/BeamRustPlugin.groovy new file mode 100644 index 000000000000..c4915b08d925 --- /dev/null +++ b/buildSrc/src/main/groovy/org/apache/beam/gradle/rust/BeamRustPlugin.groovy @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.beam.gradle.rust + +import groovy.transform.CompileStatic +import org.apache.beam.gradle.BeamModulePlugin +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.Task +import org.gradle.api.tasks.Exec + +/** + * The build of the Rust SDK ({@code :sdks:rust}). + * + *

Cargo does the work. The tasks give maintainers the same commands as the other SDKs: + * {@code build}, {@code check}, {@code test}, {@code fmt} and {@code clean}. + */ +@CompileStatic +class BeamRustPlugin implements Plugin { + + @Override + void apply(Project project) { + // BeamModulePlugin sets the project version and adds the lifecycle tasks. + project.pluginManager.apply(BeamModulePlugin) + + RustSdkExtension extension = project.extensions.create('rustSdk', RustSdkExtension) + extension.benchmarkPackages.convention(new ArrayList()) + extension.benchmarkPackages.finalizeValueOnRead() + + RustSdkBuild build = new RustSdkBuild(project, extension) + Map cargoEnv = build.versions.cargoEnv() + project.tasks.withType(Exec).configureEach { Exec task -> task.environment(cargoEnv) } + + RustLintTasks.register(build) + RustTestTasks.register(build) + + project.tasks.named('build').configure { Task task -> task.dependsOn('buildWorkspace') } + project.tasks.named('check').configure { Task task -> task.dependsOn('fmtCheck', 'clippy') } + project.tasks.named('clean').configure { Task task -> task.dependsOn('cleanSdk') } + } +} diff --git a/buildSrc/src/main/groovy/org/apache/beam/gradle/rust/BeamVersions.groovy b/buildSrc/src/main/groovy/org/apache/beam/gradle/rust/BeamVersions.groovy new file mode 100644 index 000000000000..a8fa8d80f30c --- /dev/null +++ b/buildSrc/src/main/groovy/org/apache/beam/gradle/rust/BeamVersions.groovy @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.beam.gradle.rust + +import groovy.transform.CompileStatic +import org.gradle.api.Project + +/** + * The Beam versions that each cargo command gets. + * + *

All come from gradle.properties, which release/src/main/scripts/set_version.sh bumps. + * A plain {@code cargo} build reads the same keys, so both paths report the same version. + */ +@CompileStatic +class BeamVersions { + /** The Gradle project version, for example X.Y.Z-SNAPSHOT. {@code -Pver} overrides it. */ + final String beamVersion + /** The release that it becomes, for example X.Y.Z. {@code -PbeamReleaseVersion} overrides it. */ + final String releaseVersion + /** The SDK version in binaries and container tags, for example X.Y.Z.dev. */ + final String sdkVersion + + BeamVersions(Project project) { + beamVersion = (project.findProperty('ver') ?: project.version).toString() + releaseVersion = (project.findProperty('beamReleaseVersion') + ?: beamVersion.replace('-SNAPSHOT', '')).toString() + sdkVersion = project.property('sdk_version').toString() + } + + /** The environment variables that carry the versions to cargo. */ + Map cargoEnv() { + return [ + BEAM_SDK_VERSION : sdkVersion, + BEAM_RELEASE_VERSION: releaseVersion, + BEAM_VERSION : beamVersion, + ] + } +} diff --git a/buildSrc/src/main/groovy/org/apache/beam/gradle/rust/CargoWorkspace.groovy b/buildSrc/src/main/groovy/org/apache/beam/gradle/rust/CargoWorkspace.groovy new file mode 100644 index 000000000000..327049f18b9c --- /dev/null +++ b/buildSrc/src/main/groovy/org/apache/beam/gradle/rust/CargoWorkspace.groovy @@ -0,0 +1,335 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.beam.gradle.rust + +import groovy.transform.CompileStatic +import java.util.regex.Matcher + +/** + * The crates of the Cargo workspace and the workspace crates that each one depends on. + * + *

Gradle uses this model for task inputs, so that a change to one crate runs only the + * tasks of the crates that depend on it. + */ +@CompileStatic +class CargoWorkspace { + + /** A dependency of a crate on a workspace crate. */ + static class Dep { + String alias + String targetPkg + boolean optional + boolean defaultFeatures + List features + } + + /** An entry of {@code [workspace.dependencies]} that has a path. */ + private static class WorkspaceDep { + String pkg + boolean defaultFeatures + List features + } + + /** One entry of a Cargo.toml: the section and the entry on one line. */ + private static class TomlEntry { + String section + String line + } + + /** The directory of each crate, by package name. */ + final Map crateDir = new LinkedHashMap<>() + /** The workspace crates that each crate depends on, the crate included. */ + final Map> crateClosure = new LinkedHashMap<>() + /** The crates, each one after the crates that it depends on. */ + final List topoOrder = [] + + private final Map dirToPkg = [:] + private final Map workspaceDeps = [:] + private final Map>> crateFeatures = [:] + private final Map> crateDeps = [:] + private final Map> crateDevDeps = [:] + private final Map> crateTestRequiredFeatures = [:] + + /** + * @param memberTomls the Cargo.toml of each member crate, in a stable order + * @param selectedPkg the crate of {@code -Ppkg}, or null + * @param onlyFeatures the features of {@code -PonlyFeatures} for that crate, or null + */ + CargoWorkspace(File rustDir, Collection memberTomls, String selectedPkg, String onlyFeatures) { + readWorkspaceDeps(new File(rustDir, 'Cargo.toml')) + memberTomls.each { File toml -> readPackageName(toml) } + crateDir.each { String pkg, File dir -> readManifest(pkg, dir) } + crateDir.keySet().each { String pkg -> + String features = (selectedPkg == pkg && onlyFeatures != null) ? onlyFeatures : null + crateClosure[pkg] = new ClosureResolver(pkg, features).resolve() + } + Set visited = new HashSet<>() + crateDir.keySet().sort().each { String pkg -> visitTopo(pkg, visited) } + } + + /** The library inputs of a crate. They exclude tests, benches and examples. */ + List libInputFiles(String pkg) { + File dir = crateDir[pkg] + return [ + new File(dir, 'Cargo.toml'), + new File(dir, 'build.rs'), + new File(dir, 'src'), + new File(dir, 'proto') + ].findAll { File f -> f.exists() } + } + + /** The test, bench and example directories of a crate. */ + List testInputDirs(String pkg) { + File dir = crateDir[pkg] + return ['tests', 'benches', 'examples'].collect { String sub -> new File(dir, sub) } + .findAll { File f -> f.exists() } + } + + /** Reads a Cargo.toml: removes comments and joins each multiline value into one line. */ + private static List parseToml(File tomlFile) { + List entries = [] + String section = '' + StringBuilder pending = new StringBuilder() + int depth = 0 + for (String raw : tomlFile.readLines('UTF-8')) { + String clean = raw.replaceAll(/#.*$/, '').trim() + if (clean.isEmpty()) { + continue + } + if (depth == 0 && clean.startsWith('[') && clean.endsWith(']')) { + section = clean.replaceAll(/^\[+|\]+$/, '').trim() + continue + } + if (pending.length() > 0) { + pending.append(' ') + } + pending.append(clean) + for (int i = 0; i < clean.length(); i++) { + int c = clean.charAt(i) + if ('[{'.indexOf(c) >= 0) { + depth++ + } else if (']}'.indexOf(c) >= 0) { + depth = Math.max(0, depth - 1) + } + } + if (depth == 0) { + entries.add(new TomlEntry(section: section, line: pending.toString())) + pending.setLength(0) + } + } + return entries + } + + private static List quotedStrings(String text) { + List list = [] + Matcher m = (text =~ /"([^"]+)"/) + while (m.find()) { + list.add(m.group(1)) + } + return list + } + + private static List featureArray(String rhs) { + Matcher m = (rhs =~ /features\s*=\s*\[([^\]]*)\]/) + return m.find() ? quotedStrings(m.group(1)) : new ArrayList() + } + + private static String firstGroup(String text, String pattern) { + Matcher m = (text =~ pattern) + return m.find() ? m.group(1) : null + } + + private void readWorkspaceDeps(File rootToml) { + parseToml(rootToml).each { TomlEntry entry -> + if (entry.section != 'workspace.dependencies' || !entry.line.contains('path =')) { + return + } + String[] kv = entry.line.split('=', 2) + String alias = kv[0].trim() + String rhs = kv[1].trim() + if (firstGroup(rhs, /path\s*=\s*"([^"]+)"/) == null) { + return + } + workspaceDeps[alias] = new WorkspaceDep( + pkg: firstGroup(rhs, /package\s*=\s*"([^"]+)"/) ?: alias, + defaultFeatures: !rhs.contains('default-features = false'), + features: featureArray(rhs)) + } + } + + private void readPackageName(File toml) { + TomlEntry nameEntry = parseToml(toml).find { TomlEntry entry -> + entry.section == 'package' && entry.line.startsWith('name') + } + String pkg = nameEntry == null ? null : firstGroup(nameEntry.line, /name\s*=\s*"([^"]+)"/) + if (pkg != null) { + crateDir[pkg] = toml.parentFile + dirToPkg[toml.parentFile.canonicalPath] = pkg + } + } + + private void readManifest(String pkg, File dir) { + crateFeatures[pkg] = [:] + crateDeps[pkg] = [] + crateDevDeps[pkg] = [] + crateTestRequiredFeatures[pkg] = [] + parseToml(new File(dir, 'Cargo.toml')).each { TomlEntry entry -> + String section = entry.section + String line = entry.line + if (section == 'features' && line.contains('=')) { + String[] kv = line.split('=', 2) + crateFeatures[pkg][kv[0].trim()] = quotedStrings(kv[1]) + } else if (section == 'dependencies' || section == 'build-dependencies') { + Dep dep = parseDep(dir, line) + if (dep != null) { + crateDeps[pkg].add(dep) + } + } else if (section == 'dev-dependencies') { + Dep dep = parseDep(dir, line) + if (dep != null) { + crateDevDeps[pkg].add(dep) + } + } else if ((section == 'test' || section == 'bench') && line.startsWith('required-features')) { + crateTestRequiredFeatures[pkg].addAll(quotedStrings(line)) + } + } + } + + /** Returns the dependency of this line, or null if the target is not a workspace crate. */ + private Dep parseDep(File memberDir, String line) { + if (!line.contains('=')) { + return null + } + String[] kv = line.split('=', 2) + String alias = kv[0].trim() + String rhs = kv[1].trim() + boolean fromWorkspace = rhs.contains('workspace = true') + String targetPkg = null + String packageName = firstGroup(rhs, /package\s*=\s*"([^"]+)"/) + String path = firstGroup(rhs, /path\s*=\s*"([^"]+)"/) + if (packageName != null && crateDir.containsKey(packageName)) { + targetPkg = packageName + } else if (path != null) { + targetPkg = dirToPkg[new File(memberDir, path).canonicalPath] + } else if (fromWorkspace && workspaceDeps.containsKey(alias)) { + targetPkg = workspaceDeps[alias].pkg + } + if (targetPkg == null) { + return null + } + WorkspaceDep shared = fromWorkspace ? workspaceDeps[alias] : null + return new Dep( + alias: alias, + targetPkg: targetPkg, + optional: rhs.contains('optional = true'), + defaultFeatures: !rhs.contains('default-features = false') && (shared == null || shared.defaultFeatures), + features: (featureArray(rhs) + (shared == null ? new ArrayList() : shared.features)).unique()) + } + + private void visitTopo(String pkg, Set visited) { + if (!visited.add(pkg)) { + return + } + crateClosure[pkg].each { String dep -> + if (dep != pkg && crateDir.containsKey(dep)) { + visitTopo(dep, visited) + } + } + topoOrder.add(pkg) + } + + /** Finds the workspace crates that one crate depends on, with the cargo feature rules. */ + private class ClosureResolver { + private final String rootPkg + private final String onlyFeatures + private final Set activeCrates = new LinkedHashSet<>() + private final Set enabledFeatures = new LinkedHashSet<>() + private final Set activatedEdges = new LinkedHashSet<>() + + ClosureResolver(String rootPkg, String onlyFeatures) { + this.rootPkg = rootPkg + this.onlyFeatures = onlyFeatures + } + + Set resolve() { + activateCrate(rootPkg) + return activeCrates + } + + private void activateCrate(String pkg) { + if (!activeCrates.add(pkg)) { + return + } + depsOf(pkg).findAll { Dep d -> !d.optional }.each { Dep d -> activateEdge(pkg, d) } + if (pkg != rootPkg) { + return + } + (crateDevDeps[pkg] ?: new ArrayList()).findAll { Dep d -> !d.optional } + .each { Dep d -> activateEdge(pkg, d) } + if (onlyFeatures != null) { + onlyFeatures.split(',').collect { String f -> f.trim() }.findAll { String f -> !f.isEmpty() } + .each { String f -> enableFeature(pkg, f) } + } else { + enableFeature(pkg, 'default') + (crateTestRequiredFeatures[pkg] ?: new ArrayList()).each { String f -> enableFeature(pkg, f) } + } + } + + private void activateEdge(String fromPkg, Dep d) { + String edgeKey = "${fromPkg}->${d.alias}:${d.targetPkg}:${d.defaultFeatures}:${d.features.join(',')}" + if (!activatedEdges.add(edgeKey)) { + return + } + activateCrate(d.targetPkg) + if (d.defaultFeatures) { + enableFeature(d.targetPkg, 'default') + } + d.features.each { String f -> enableFeature(d.targetPkg, f) } + } + + private void enableFeature(String pkg, String feature) { + activateCrate(pkg) + if (!enabledFeatures.add("${pkg}:${feature}".toString())) { + return + } + depsOf(pkg).findAll { Dep d -> d.optional && d.alias == feature }.each { Dep d -> activateEdge(pkg, d) } + List tokens = (crateFeatures[pkg] ?: new HashMap>())[feature] + (tokens ?: new ArrayList()).each { String token -> + if (token.startsWith('dep:')) { + String depAlias = token.substring(4) + depsOf(pkg).findAll { Dep d -> d.alias == depAlias }.each { Dep d -> activateEdge(pkg, d) } + } else if (token.contains('/')) { + String[] parts = token.split('/', 2) + String depAlias = parts[0].replace('?', '') + depsOf(pkg).findAll { Dep d -> d.alias == depAlias }.each { Dep d -> + if (!parts[0].endsWith('?')) { + activateEdge(pkg, d) + } + enableFeature(d.targetPkg, parts[1]) + } + } else { + enableFeature(pkg, token) + } + } + } + + private List depsOf(String pkg) { + return crateDeps[pkg] ?: new ArrayList() + } + } +} diff --git a/buildSrc/src/main/groovy/org/apache/beam/gradle/rust/RustLintTasks.groovy b/buildSrc/src/main/groovy/org/apache/beam/gradle/rust/RustLintTasks.groovy new file mode 100644 index 000000000000..970599fd8cad --- /dev/null +++ b/buildSrc/src/main/groovy/org/apache/beam/gradle/rust/RustLintTasks.groovy @@ -0,0 +1,115 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.beam.gradle.rust + +import groovy.transform.CompileStatic +import org.gradle.api.Action +import org.gradle.api.tasks.Exec +import org.gradle.api.tasks.PathSensitivity +import org.gradle.process.ExecSpec + +/** The build, format, lint and clean tasks. */ +@CompileStatic +class RustLintTasks { + + /** The lints that test and benchmark code can break. clippy.toml exempts {@code #[cfg(test)]}. */ + private static final List TEST_CLIPPY_ALLOWS = [ + 'unwrap_used', + 'expect_used', + 'panic', + 'missing_panics_doc', + ].collectMany { String lint -> ['-A', "clippy::${lint}".toString()] } + + static void register(RustSdkBuild build) { + registerBuildWorkspace(build) + registerFmt(build) + registerClippy(build) + build.cargoTask('cleanSdk', 'Build', 'Remove the cargo target directory', ['clean']) + } + + private static void registerBuildWorkspace(RustSdkBuild build) { + build.cargoTask('buildWorkspace', 'Build', + 'Compile all crates in the Rust workspace but the benchmarks (or one crate with -Ppkg=)', + ['build'] + build.cargoScope).configure { Exec task -> + String pkg = build.selectedPkg + CargoWorkspace workspace = build.workspace + task.inputs.property('beamSdkVersion', build.versions.sdkVersion) + task.inputs.property('cargoScope', build.cargoScope) + task.inputs.files(build.workspaceRootFiles).withPathSensitivity(PathSensitivity.RELATIVE) + task.inputs.files(build.modelProtoDirs).withPathSensitivity(PathSensitivity.RELATIVE) + task.inputs.files(build.project.provider { + if (pkg != null && workspace.crateClosure.containsKey(pkg)) { + List inputs = [] + workspace.crateClosure[pkg].each { String dep -> inputs.addAll(workspace.libInputFiles(dep)) } + inputs.addAll(build.testInputFiles(pkg)) + return inputs + } + return build.libAndTestInputs(build.defaultPackages()) + }).withPathSensitivity(PathSensitivity.RELATIVE) + String buildKey = pkg != null + ? "${pkg}-${build.onlyFeatures ?: 'default'}".replaceAll('[^a-zA-Z0-9_-]', '_') + : 'workspace' + File stampFile = build.buildFile("test-results/cargo/build-${buildKey}.txt") + task.outputs.file(stampFile) + // Cargo decides what to compile; Gradle only skips the call when no input changed. + task.outputs.upToDateWhen { new File(build.rustDir, 'target').exists() } + task.doLast { RustSdkBuild.writeStamp(stampFile) } + } + } + + private static void registerFmt(RustSdkBuild build) { + build.cargoTask('fmtCheck', 'Verification', 'Verify formatting (cargo fmt --check)', + ['fmt', '--check']).configure { Exec task -> + task.inputs.files(new File(build.rustDir, 'rustfmt.toml'), new File(build.rustDir, 'Cargo.toml')) + .withPathSensitivity(PathSensitivity.RELATIVE) + task.inputs.files(build.libAndTestInputs(build.workspace.topoOrder)) + .withPathSensitivity(PathSensitivity.RELATIVE) + File stampFile = build.buildFile('test-results/cargo/fmtCheck.txt') + task.outputs.file(stampFile) + task.outputs.cacheIf { true } + task.doLast { RustSdkBuild.writeStamp(stampFile) } + } + build.cargoTask('fmt', 'Verification', 'Format all Rust code (cargo fmt)', ['fmt']) + } + + private static void registerClippy(RustSdkBuild build) { + build.cargoTask('clippy', 'Verification', 'Run clippy on all targets (-D warnings)', + ['clippy'] + build.workspaceScope + ['--lib', '--bins', '--examples', '--', '-D', 'warnings']) + .configure { Exec task -> + task.mustRunAfter('fmtCheck') + task.inputs.property('beamSdkVersion', build.versions.sdkVersion) + task.inputs.files(build.workspaceRootFiles + [new File(build.rustDir, 'clippy.toml')]) + .withPathSensitivity(PathSensitivity.RELATIVE) + task.inputs.files(build.modelProtoDirs).withPathSensitivity(PathSensitivity.RELATIVE) + task.inputs.files(build.project.provider { build.libAndTestInputs(build.defaultPackages()) }) + .withPathSensitivity(PathSensitivity.RELATIVE) + File stampFile = build.buildFile('test-results/cargo/clippy.txt') + task.outputs.file(stampFile) + task.outputs.cacheIf { true } + task.doLast { + build.project.exec({ ExecSpec spec -> + spec.workingDir(build.rustDir) + spec.environment(build.versions.cargoEnv()) + spec.commandLine(['cargo', 'clippy'] + build.workspaceScope + + ['--tests', '--benches', '--', '-D', 'warnings'] + TEST_CLIPPY_ALLOWS) + } as Action) + RustSdkBuild.writeStamp(stampFile) + } + } + } +} diff --git a/buildSrc/src/main/groovy/org/apache/beam/gradle/rust/RustSdkBuild.groovy b/buildSrc/src/main/groovy/org/apache/beam/gradle/rust/RustSdkBuild.groovy new file mode 100644 index 000000000000..225b845f3235 --- /dev/null +++ b/buildSrc/src/main/groovy/org/apache/beam/gradle/rust/RustSdkBuild.groovy @@ -0,0 +1,132 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.beam.gradle.rust + +import groovy.transform.CompileStatic +import org.gradle.api.Project +import org.gradle.api.file.ConfigurableFileTree +import org.gradle.api.tasks.Exec +import org.gradle.api.tasks.TaskProvider + +/** The settings that the task groups of the Rust SDK build share. */ +@CompileStatic +class RustSdkBuild { + final Project project + final RustSdkExtension extension + final BeamVersions versions + /** The root of the Cargo workspace. */ + final File rustDir + final CargoWorkspace workspace + + /** The crate of {@code -Ppkg=}, or null for the workspace. */ + final String selectedPkg + /** With {@code -Ppkg}, the only cargo features of {@code -PonlyFeatures=}, or null. */ + final String onlyFeatures + final List workspaceScope = ['--workspace'] + final List featureScope + /** The cargo arguments that select the crate of {@code -Ppkg}, or the workspace. */ + final List cargoScope + /** The arguments of {@code -PtestArgs=""}, which go to the test binary after {@code --}. */ + final List testArgs + /** With {@code --continue}, cargo runs each test binary and reports all failures. */ + final List noFailFast + + final List modelProtoDirs + final List workspaceRootFiles + /** The {@code test_} task of each crate. */ + final Map> testTasks = new LinkedHashMap<>() + + RustSdkBuild(Project project, RustSdkExtension extension) { + this.project = project + this.extension = extension + versions = new BeamVersions(project) + rustDir = new File(project.rootDir, 'sdks/rust') + + selectedPkg = (project.findProperty('pkg') ?: project.findProperty('package'))?.toString() + onlyFeatures = project.findProperty('onlyFeatures')?.toString() + featureScope = (selectedPkg != null && onlyFeatures != null) + ? ['--no-default-features', '--features', onlyFeatures] : new ArrayList() + cargoScope = (selectedPkg != null ? ['-p', selectedPkg] : workspaceScope) + featureScope + testArgs = project.findProperty('testArgs')?.toString()?.tokenize() ?: new ArrayList() + noFailFast = project.gradle.startParameter.continueOnFailure + ? ['--no-fail-fast'] : new ArrayList() + + ConfigurableFileTree memberTomls = project.fileTree(rustDir) + memberTomls.include('**/Cargo.toml') + memberTomls.exclude('Cargo.toml', 'target/**', 'container/**', 'build/**', 'examples/build/**') + workspace = new CargoWorkspace( + rustDir, memberTomls.files.sort { File f -> f.absolutePath }, selectedPkg, onlyFeatures) + + modelProtoDirs = [ + 'model/pipeline/src/main/proto', + 'model/fn-execution/src/main/proto', + 'model/job-management/src/main/proto', + ].collect { String path -> new File(project.rootDir, path) } + workspaceRootFiles = [ + new File(rustDir, 'Cargo.toml'), + new File(rustDir, 'Cargo.lock'), + new File(project.rootDir, 'gradle.properties'), + ] + } + + /** Registers an Exec task that runs {@code cargo } in the workspace root. */ + TaskProvider cargoTask(String name, String taskGroup, String text, List args) { + return project.tasks.register(name, Exec) { Exec task -> + task.group = taskGroup + task.description = text + task.workingDir(rustDir) + task.commandLine(['cargo'] + args) + } + } + + /** The crates of the default {@code test}: all but the benchmark crates. */ + List defaultPackages() { + List benchmarks = extension.benchmarkPackages.get() + return workspace.topoOrder.findAll { String pkg -> !(pkg in benchmarks) } + } + + /** The test, bench and example files of a crate, without the Python suites in them. */ + List testInputFiles(String pkg) { + return workspace.testInputDirs(pkg).collect { File dir -> + ConfigurableFileTree tree = project.fileTree(dir) + tree.exclude('python/**', '**/__pycache__/**', '**/.pytest_cache/**') + return tree + } + } + + /** The library and test inputs of these crates. */ + List libAndTestInputs(Collection packages) { + List inputs = [] + packages.each { String pkg -> + inputs.addAll(workspace.libInputFiles(pkg)) + inputs.addAll(testInputFiles(pkg)) + } + return inputs + } + + /** A file in the build directory of the project. */ + File buildFile(String path) { + return new File(project.layout.buildDirectory.get().asFile, path) + } + + /** Writes the stamp file that marks a task with no other output as done. */ + static void writeStamp(File stampFile, String text = 'ok\n') { + stampFile.parentFile.mkdirs() + stampFile.text = text + } +} diff --git a/buildSrc/src/main/groovy/org/apache/beam/gradle/rust/RustSdkExtension.groovy b/buildSrc/src/main/groovy/org/apache/beam/gradle/rust/RustSdkExtension.groovy new file mode 100644 index 000000000000..a24842eaa9f3 --- /dev/null +++ b/buildSrc/src/main/groovy/org/apache/beam/gradle/rust/RustSdkExtension.groovy @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.beam.gradle.rust + +import groovy.transform.CompileStatic +import org.gradle.api.provider.ListProperty + +/** The settings of the Rust SDK build: the {@code rustSdk} block of sdks/rust/build.gradle.kts. */ +@CompileStatic +abstract class RustSdkExtension { + /** The benchmark crates. The default {@code test} does not run them. */ + abstract ListProperty getBenchmarkPackages() +} diff --git a/buildSrc/src/main/groovy/org/apache/beam/gradle/rust/RustTestTasks.groovy b/buildSrc/src/main/groovy/org/apache/beam/gradle/rust/RustTestTasks.groovy new file mode 100644 index 000000000000..c04e85db1c65 --- /dev/null +++ b/buildSrc/src/main/groovy/org/apache/beam/gradle/rust/RustTestTasks.groovy @@ -0,0 +1,255 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.beam.gradle.rust + +import groovy.transform.CompileStatic +import java.util.regex.Matcher +import org.gradle.api.GradleException +import org.gradle.api.Task +import org.gradle.api.logging.Logger +import org.gradle.api.tasks.Exec +import org.gradle.api.tasks.PathSensitivity +import org.gradle.api.tasks.TaskProvider + +/** + * The test tasks: one cacheable {@code test_} task for each crate, {@code test} and + * {@code testSummary}. + * + *

The inputs of {@code test_} are the sources and tests of the crate, and the library + * sources of the workspace crates that it depends on. A change to a test of one crate does + * not run the tests of the crates that depend on it. + */ +@CompileStatic +class RustTestTasks { + + /** The test counts of one crate. */ + private static class Counts { + int passed + int failed + int ignored + int filtered + String status + } + + /** Writes to the console and keeps a copy, so that the task can count the results. */ + private static class TeeOutputStream extends OutputStream { + final ByteArrayOutputStream captured = new ByteArrayOutputStream() + + @Override + void write(int b) { + System.out.write(b) + captured.write(b) + } + + @Override + void write(byte[] b, int off, int len) { + System.out.write(b, off, len) + captured.write(b, off, len) + } + + @Override + void flush() { + System.out.flush() + } + } + + static void register(RustSdkBuild build) { + Map results = new LinkedHashMap<>() + Map stampFiles = new LinkedHashMap<>() + + // Each test task runs after the previous one, so cargo processes do not wait on + // target/.cargo-lock, and base crates run before the crates that depend on them. + String previousTask = 'clippy' + for (String pkg : build.workspace.topoOrder) { + stampFiles[pkg] = stampFile(build, pkg) + build.testTasks[pkg] = registerCrateTest(build, pkg, previousTask, stampFiles[pkg], results) + previousTask = "test_${pkg}".toString() + } + registerSummary(build, results, stampFiles) + registerTest(build) + } + + private static File stampFile(RustSdkBuild build, String pkg) { + boolean ownFeatures = build.selectedPkg == pkg && build.onlyFeatures != null + String featureSuffix = ownFeatures + ? "-features-${build.onlyFeatures.replaceAll('[^a-zA-Z0-9_-]', '_')}" : '' + String filterSuffix = build.testArgs ? '-filtered' : '' + return build.buildFile("test-results/cargo/${pkg}/test${featureSuffix}${filterSuffix}.txt") + } + + private static TaskProvider registerCrateTest( + RustSdkBuild build, String pkg, String runAfter, File stampFile, Map results) { + List testArgs = build.testArgs + List featureScope = build.selectedPkg == pkg ? build.featureScope : new ArrayList() + Set closure = build.workspace.crateClosure[pkg] + + return build.project.tasks.register("test_${pkg}".toString(), Exec) { Exec task -> + task.group = 'Verification' + task.description = "Run cargo test for ${pkg}" + task.workingDir(build.rustDir) + task.commandLine(['cargo', 'test', '-p', pkg] + featureScope + build.noFailFast + + (testArgs ? ['--'] + testArgs : new ArrayList())) + task.ignoreExitValue = true + task.finalizedBy('testSummary') + task.mustRunAfter(runAfter, 'buildWorkspace') + + task.inputs.property('pkg', pkg) + task.inputs.property('beamSdkVersion', build.versions.sdkVersion) + task.inputs.property('beamReleaseVersion', build.versions.releaseVersion) + task.inputs.property('featureScope', featureScope) + task.inputs.property('testArgs', testArgs) + task.inputs.files(build.workspaceRootFiles).withPathSensitivity(PathSensitivity.RELATIVE) + if ('apache-beam-model' in closure) { + task.inputs.files(build.modelProtoDirs).withPathSensitivity(PathSensitivity.RELATIVE) + } + closure.each { String dep -> + task.inputs.files(build.workspace.libInputFiles(dep)).withPathSensitivity(PathSensitivity.RELATIVE) + } + task.inputs.files(build.testInputFiles(pkg)).withPathSensitivity(PathSensitivity.RELATIVE) + + task.outputs.file(stampFile) + task.outputs.upToDateWhen { testArgs.isEmpty() && readStamp(stampFile) != null } + task.outputs.cacheIf { testArgs.isEmpty() } + + TeeOutputStream output = new TeeOutputStream() + task.doFirst { + output.captured.reset() + task.standardOutput = output + } + task.doLast { + Counts counts = countResults(output.captured.toString('UTF-8'), testArgs.isEmpty()) + task.logger.lifecycle("Total for ${pkg}: ${counts.passed} passed; ${counts.failed} failed; " + + "${counts.ignored} ignored; ${counts.filtered} filtered out") + int exitCode = task.executionResult.get().exitValue + counts.status = exitCode == 0 ? 'EXECUTED' : 'FAILED' + results[pkg] = counts + if (exitCode != 0) { + stampFile.delete() + task.executionResult.get().assertNormalExitValue() + } + RustSdkBuild.writeStamp(stampFile, "passed=${counts.passed} failed=${counts.failed} " + + "ignored=${counts.ignored} filtered=${counts.filtered}\n") + } + } + } + + /** Adds the {@code test result:} lines of the cargo output. */ + private static Counts countResults(String output, boolean noFilter) { + Counts total = new Counts() + Matcher m = (output =~ + /test result: (?:ok|FAILED)\. (\d+) passed; (\d+) failed; (\d+) ignored; \d+ measured; (\d+) filtered out/) + while (m.find()) { + int filtered = m.group(4) as int + // A test that runs its own binary with `--exact` prints a second line with a filter. + if (noFilter && filtered > 0) { + continue + } + total.passed += m.group(1) as int + total.failed += m.group(2) as int + total.ignored += m.group(3) as int + total.filtered += filtered + } + return total + } + + /** Reads the counts of a stamp file, or null if the file has none. */ + private static Counts readStamp(File stampFile) { + if (!stampFile.isFile()) { + return null + } + Matcher m = (stampFile.text =~ /passed=(\d+)\s+failed=(\d+)\s+ignored=(\d+)\s+filtered=(\d+)/) + if (!m.find()) { + return null + } + return new Counts( + passed: m.group(1) as int, + failed: m.group(2) as int, + ignored: m.group(3) as int, + filtered: m.group(4) as int) + } + + private static void registerSummary( + RustSdkBuild build, Map results, Map stampFiles) { + build.project.tasks.register('testSummary') { Task task -> + task.group = 'Verification' + task.description = 'Print the aggregated per-crate test summary' + task.mustRunAfter(build.testTasks.values()) + task.doLast { + List packages = build.selectedPkg != null ? [build.selectedPkg] : build.defaultPackages() + Map rows = new LinkedHashMap<>() + packages.each { String pkg -> + Counts counts = results[pkg] + if (counts == null && stampFiles[pkg] != null) { + counts = readStamp(stampFiles[pkg]) + if (counts != null) { + counts.status = 'UP-TO-DATE' + } + } + if (counts != null) { + rows[pkg] = counts + } + } + printSummary(task.logger, rows) + } + } + } + + private static void printSummary(Logger logger, Map rows) { + if (rows.isEmpty()) { + return + } + int nameWidth = Math.max(28, rows.keySet().collect { String pkg -> pkg.length() }.max() + 2) + String separator = '-' * (nameWidth + 46) + String rowFormat = "%-${nameWidth}s %8d %8d %9d %10d" + logger.lifecycle(separator) + logger.lifecycle(String.format("%-${nameWidth}s %8s %8s %9s %10s %s", + 'Crate', 'Passed', 'Failed', 'Ignored', 'Filtered', 'Status')) + logger.lifecycle(separator) + rows.each { String pkg, Counts c -> + logger.lifecycle(String.format("${rowFormat} %s", pkg, c.passed, c.failed, c.ignored, c.filtered, c.status)) + } + logger.lifecycle(separator) + logger.lifecycle(String.format(rowFormat, + "Total (${rows.size()} ${rows.size() == 1 ? 'crate' : 'crates'})".toString(), + rows.values().sum { Counts c -> c.passed }, + rows.values().sum { Counts c -> c.failed }, + rows.values().sum { Counts c -> c.ignored }, + rows.values().sum { Counts c -> c.filtered })) + logger.lifecycle(separator) + } + + private static void registerTest(RustSdkBuild build) { + build.project.tasks.register('test') { Task task -> + task.group = 'Verification' + task.description = 'Run tests (the workspace, or one crate with -Ppkg=; ' + + '-PtestArgs= after --; --continue runs every test binary)' + task.finalizedBy('testSummary') + String pkg = build.selectedPkg + if (pkg == null) { + task.dependsOn(build.project.provider { + build.defaultPackages().collect { String name -> build.testTasks[name] } + }) + } else if (build.testTasks.containsKey(pkg)) { + task.dependsOn(build.testTasks[pkg]) + } else { + throw new GradleException("Unknown Rust workspace package '${pkg}'. " + + "Available packages: ${build.workspace.topoOrder.join(', ')}") + } + } + } +} diff --git a/dev-support/docker/pkglist b/dev-support/docker/pkglist index 2a9bc73a9719..6d745c265320 100644 --- a/dev-support/docker/pkglist +++ b/dev-support/docker/pkglist @@ -42,5 +42,6 @@ python3.12-venv python3.13 python3.13-dev python3.13-venv +protobuf-compiler tox docker.io diff --git a/local-env-setup.sh b/local-env-setup.sh index d373cd71ea32..019d290e3813 100755 --- a/local-env-setup.sh +++ b/local-env-setup.sh @@ -68,6 +68,13 @@ if [ "$kernelname" = "Linux" ]; then exit fi + type -P rustc > /dev/null 2>&1 + rustExists=$? + if [ $rustExists -ne 0 ]; then + echo "Installing rust via rustup..." + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + fi + # Running on Mac elif [ "$kernelname" = "Darwin" ]; then # Check for Homebrew, install if we don't have it @@ -144,5 +151,23 @@ elif [ "$kernelname" = "Darwin" ]; then exit fi + type -P rustc > /dev/null 2>&1 + rustExists=$? + if [ $rustExists -eq 0 ]; then + echo "rust already installed. Skipping" + else + echo "Installing rust" + brew install rust + fi + + type -P protoc > /dev/null 2>&1 + protocExists=$? + if [ $protocExists -eq 0 ]; then + echo "protobuf already installed. Skipping" + else + echo "Installing protobuf" + brew install protobuf + fi + else echo "Unrecognized Kernel Name: $kernelname" fi diff --git a/release/src/main/scripts/set_version.sh b/release/src/main/scripts/set_version.sh index 138275f20a32..681b83261556 100755 --- a/release/src/main/scripts/set_version.sh +++ b/release/src/main/scripts/set_version.sh @@ -92,11 +92,13 @@ if [[ -z "$IS_SNAPSHOT_VERSION" ]] ; then sed -i -e "s/SdkVersion = .*/SdkVersion = \"$TARGET_VERSION\"/" sdks/go/pkg/beam/core/core.go sed -i -e "s/\"version\": .*/\"version\": \"$TARGET_VERSION\",/" sdks/typescript/package.json sed -i -e "s/DEFAULT_BEAM_VERSION=\".*\"/DEFAULT_BEAM_VERSION=\"$TARGET_VERSION\"/" scripts/beam-sql.sh + sdks/rust/scripts/set_version.sh "$TARGET_VERSION" else # For snapshot version: # Java/gradle appends -SNAPSHOT # In the Gradle plugin, the -SNAPSHOT is dynamic so we don't add it here # Python appends .dev + # Rust appends -SNAPSHOT (Cargo requires semver) # The Dataflow container remains unchanged as in this case it is beam-master- form sed -i -e "s/version=.*/version=$TARGET_VERSION-SNAPSHOT/" gradle.properties sed -i -e "s/project.version = .*/project.version = '$TARGET_VERSION'/" buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy @@ -105,6 +107,7 @@ else sed -i -e "s/SdkVersion = .*/SdkVersion = \"${TARGET_VERSION}.dev\"/" sdks/go/pkg/beam/core/core.go sed -i -e "s/\"version\": .*/\"version\": \"$TARGET_VERSION-SNAPSHOT\",/" sdks/typescript/package.json sed -i -e "s/DEFAULT_BEAM_VERSION=\".*\"/DEFAULT_BEAM_VERSION=\"$TARGET_VERSION\"/" scripts/beam-sql.sh + sdks/rust/scripts/set_version.sh "$TARGET_VERSION-SNAPSHOT" fi if [[ "$GIT_ADD" == yes ]] ; then @@ -115,4 +118,5 @@ if [[ "$GIT_ADD" == yes ]] ; then git add runners/google-cloud-dataflow-java/build.gradle git add sdks/typescript/package.json git add scripts/beam-sql.sh + git add 'sdks/rust/*Cargo.toml' sdks/rust/Cargo.lock fi diff --git a/sdks/rust/Cargo.lock b/sdks/rust/Cargo.lock new file mode 100644 index 000000000000..778945b7dd81 --- /dev/null +++ b/sdks/rust/Cargo.lock @@ -0,0 +1,1187 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aho-corasick" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" +dependencies = [ + "memchr", +] + +[[package]] +name = "anyhow" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" + +[[package]] +name = "apache-beam-model" +version = "2.79.0-SNAPSHOT" +dependencies = [ + "prost", + "prost-types", + "tonic", + "tonic-prost", + "tonic-prost-build", +] + +[[package]] +name = "async-trait" +version = "0.1.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82f6aeea286b8eb4dd3431a1be1b59d290ace00f5bfd8e2a159bc2a05e2c1667" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "axum" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31b698c5f9a010f6573133b09e0de5408834d0c82f8d7475a89fc1867a71cd90" +dependencies = [ + "axum-core", + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "serde_core", + "sync_wrapper", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08c78f31d7b1291f7ee735c1c6780ccde7785daae9a9206026862dab7d8792d1" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "sync_wrapper", + "tower-layer", + "tower-service", +] + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" + +[[package]] +name = "bytes" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" + +[[package]] +name = "cc" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6651c9ed80effdc7db0ff72512157f901af5e3549e341e24b1dd4887d836d838" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "either" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "252afb9ae5eaa683babdc6a068b3f5726eb19e05070c731f9b2a23a7c3e8ed34" + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "fastrand" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" + +[[package]] +name = "find-msvc-tools" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aedcfb3409746eddb02b9e19ebda1c3394f759a152e48ee875a0844d1b955484" + +[[package]] +name = "fixedbitset" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "futures-channel" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-sink" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d" + +[[package]] +name = "futures-task" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" + +[[package]] +name = "futures-util" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "slab", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "libc", + "r-efi", +] + +[[package]] +name = "h2" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef8e5e5a340588f4452631496976cf8636d4a7ecf600239fdc27615d2530bc16" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash", +] + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "http" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "918d3568bebf352712bc2ef3d46a8bcf1a75b373be6539de198e9105cbbf9ce0" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2a8f2913ee65f60facd6a5905613afaa448497a0230cc41ce022d93290bc2c" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23169fe34a5fbcdd3f3862e78fb9b6fccd5f02a6dc6f732547005d45631ce71c" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27b501faa50e7a26c3d3560ca625132f4078a17771f4810baf70475ae48cbe43" +dependencies = [ + "atomic-waker", + "bytes", + "futures-channel", + "futures-core", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-timeout" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" +dependencies = [ + "hyper", + "hyper-util", + "pin-project-lite", + "tokio", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "libc", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", +] + +[[package]] +name = "indexmap" +version = "2.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" +dependencies = [ + "equivalent", + "hashbrown 0.17.1", +] + +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "libc" +version = "0.2.189" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2" + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "log" +version = "0.4.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" + +[[package]] +name = "matchit" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mio" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b18443e9c262bfe8fa82f51666e2642c53393f7e5c27b3e1aeab922cff5b9d8" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "multimap" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d87ecb2933e8aeadb3e3a02b828fed80a7528047e68b4f424523a0981a3a084" + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "openssl-probe" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "petgraph" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455" +dependencies = [ + "fixedbitset", + "hashbrown 0.15.5", + "indexmap", +] + +[[package]] +name = "pin-project" +version = "1.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2466b2336ed02bcdca6b294417127b90ec92038d1d5c4fbeac971a922e0e0924" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c96395f0a926bc13b1c17622aaddda1ecb55d49c8f1bf9777e4d877800a43f8b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn 2.0.119", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "prost" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "528ac67416ff8646872a3c02cad9cc4ee5dc9f9540c9b10771855c95cb2e5ae1" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-build" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03da047801ff44bb6a4d407d4860c05fd70bb81714e6b2f3812603d5b145b042" +dependencies = [ + "heck", + "itertools", + "log", + "multimap", + "petgraph", + "prettyplease", + "prost", + "prost-types", + "pulldown-cmark", + "pulldown-cmark-to-cmark", + "regex", + "syn 2.0.119", + "tempfile", +] + +[[package]] +name = "prost-derive" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b570b25f7617e43d59005d0990ccb79e950a423952cea19671b7a876da390adf" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "prost-types" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f94967dc7688f3054c7fac87473ffae4cc4c3904800e2d9f5b857246d8963b0a" +dependencies = [ + "prost", +] + +[[package]] +name = "pulldown-cmark" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9f068eba8e7071c5f9511831b44f32c740d5adf574e990f946ddb53db2f314e" +dependencies = [ + "bitflags", + "memchr", + "unicase", +] + +[[package]] +name = "pulldown-cmark-to-cmark" +version = "22.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab1ad36992cead65f02aa399a373a42730922f1525d988172634fdefdecb8a60" +dependencies = [ + "pulldown-cmark", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "regex" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.17", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustix" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891efababe418670775f199f0d233d84843c227a0949a883ce15b37c78d6629d" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls" +version = "0.23.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf" +dependencies = [ + "log", + "once_cell", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-native-certs" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a073f5dc7469f984c52ad2752b63b0807745133b6de880b7b64c1ac4c48aec4" +dependencies = [ + "openssl-probe", + "rustls-pki-types", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-pki-types" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f4925028c7eb5d1fcdaf196971378ed9d2c1c4efc7dc5d011256f76c99c0a96" +dependencies = [ + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4443b1b6d39d7c663139942cc4558262562d2c84123bb6282ef177009ca8b281" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "schannel" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91c1b7e4904c873ef0710c1f407dde2e6287de2bebc1bbbf7d430bb7cbffd939" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "security-framework" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba467056f1b547ed52077911161fc86985becbc60e8e1857c8a144dab0def891" + +[[package]] +name = "socket2" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8593e8e72159ed2257d083c7a454a85cbf854f37a0966d8d483aff8c8a3ebcee" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" + +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand", + "getrandom 0.4.3", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio" +version = "1.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "202caea871b69668250d242070849eb495be178ed697a3e98aebce5bc81a0bed" +dependencies = [ + "bytes", + "libc", + "mio", + "pin-project-lite", + "socket2", + "tokio-macros", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-macros" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9cc2678c2cdd569ef8215e2afd7954ada2ae20b4fdd2c5fe6139a3b02d105db" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-stream" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3d06f0b082ba57c26b79407372e57cf2a1e28124f78e9479fe80322cf53420b" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "494815d09bf52b5548659851081238f0ca39ff638363907596da739561c62c52" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "libc", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tonic" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac2a5518c70fa84342385732db33fb3f44bc4cc748936eb5833d2df34d6445ef" +dependencies = [ + "async-trait", + "axum", + "base64", + "bytes", + "h2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-timeout", + "hyper-util", + "percent-encoding", + "pin-project", + "rustls-native-certs", + "socket2", + "sync_wrapper", + "tokio", + "tokio-rustls", + "tokio-stream", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tonic-build" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c68f61875ac5293cf72e6c8cf0158086428c82c37229e98c840878f1706b0322" +dependencies = [ + "prettyplease", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "tonic-prost" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50849f68853be452acf590cde0b146665b8d507b3b8af17261df47e02c209ea0" +dependencies = [ + "bytes", + "prost", + "tonic", +] + +[[package]] +name = "tonic-prost-build" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "654e5643eff75d7f8c99197ce1440ed19a3474eada74c12bbac488b2cafdae27" +dependencies = [ + "prettyplease", + "proc-macro2", + "prost-build", + "prost-types", + "quote", + "syn 2.0.119", + "tempfile", + "tonic-build", +] + +[[package]] +name = "tower" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" +dependencies = [ + "futures-core", + "futures-util", + "indexmap", + "pin-project-lite", + "slab", + "sync_wrapper", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "unicase" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbc4bc3a9f746d862c45cb89d705aa10f187bb96c76001afab07a0d35ce60142" + +[[package]] +name = "unicode-ident" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "zeroize" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13084392c5e4bc371903e2935a5eaeed24905a7511356b883835e18a78f6879" diff --git a/sdks/rust/Cargo.toml b/sdks/rust/Cargo.toml new file mode 100644 index 000000000000..431835a87545 --- /dev/null +++ b/sdks/rust/Cargo.toml @@ -0,0 +1,86 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +[workspace] +resolver = "3" +members = [ + "beam/model", +] + +[workspace.package] +version = "2.79.0-SNAPSHOT" +edition = "2024" +rust-version = "1.98" +license = "Apache-2.0" +repository = "https://github.com/apache/beam" +homepage = "https://beam.apache.org" + +# Unused-code lints that rustc leaves allow-by-default, so `-D warnings` does not reach +# them. Declared here rather than on the Gradle command line so the IDE and a bare +# `cargo clippy` enforce the same set. Each member opts in with `[lints] workspace = true`. +[workspace.lints.rust] +unused_qualifications = "warn" +unused_lifetimes = "warn" +unused_import_braces = "warn" +unused_macro_rules = "warn" +single_use_lifetimes = "warn" + +[workspace.lints.clippy] +redundant_clone = "warn" +# Give a reason for each suppression. Use #[expect], so that stale ones cause a warning. +allow_attributes_without_reason = "warn" +# Library code reports errors instead of panicking; see clippy.toml for tests. +unwrap_used = "warn" +expect_used = "warn" +panic = "warn" +missing_panics_doc = "warn" +# Explain why every `unsafe` block is sound. +undocumented_unsafe_blocks = "warn" +# Leftover debugging. +dbg_macro = "warn" +todo = "warn" +# Ownership and unnecessary clones. +clone_on_ref_ptr = "warn" +needless_pass_by_value = "warn" +cloned_instead_of_copied = "warn" +large_types_passed_by_value = "warn" +rc_buffer = "warn" +# Style and control flow. +match_bool = "warn" +match_wildcard_for_single_variants = "warn" +redundant_else = "warn" +if_not_else = "warn" +uninlined_format_args = "warn" +manual_let_else = "warn" +semicolon_if_nothing_returned = "warn" + +[workspace.dependencies] +prost = "0.14" +prost-types = "0.14" +tonic = { version = "0.14", features = ["tls-native-roots"] } +tonic-prost = "0.14" +tonic-prost-build = "0.14" + +# Keep file:line in panic backtraces without full DWARF debug info. +[profile.dev] +debug = "line-tables-only" + +# Omit debug info for third-party dependencies to speed up linking. +[profile.dev.package."*"] +debug = false + +# The test profile inherits from dev, so it picks up both settings above. diff --git a/sdks/rust/README.md b/sdks/rust/README.md new file mode 100644 index 000000000000..8b0ed9007d7e --- /dev/null +++ b/sdks/rust/README.md @@ -0,0 +1,50 @@ + + +# Rust SDK + +A library for writing [Apache Beam](https://beam.apache.org/) pipelines in Rust. + +The SDK is under active development. The design and its review are in the +RFC shared on the dev@beam.apache.org mailing list. + +## Crate Layout + +The SDK is a Cargo workspace with its root at `sdks/rust`: + +| Crate | Path | Contents | +| :--- | :--- | :--- | +| `apache-beam-model` | `beam/model/` | Protobuf and gRPC bindings generated from the standard Beam model protos. | + +## Building and Testing + +Run builds through Gradle, like the rest of the Beam repository: + +```bash +./gradlew :sdks:rust:build # Compile all crates +./gradlew :sdks:rust:test # Run all tests (one crate: -Ppkg=) +./gradlew :sdks:rust:check # rustfmt --check + clippy -D warnings +./gradlew :sdks:rust:fmt # Apply formatting +``` + +For the full task reference, see [docs/development.md](docs/development.md). + +## Contributing + +See the [Beam Contribution Guide](https://beam.apache.org/contribute/). Each new file must have the standard Apache 2.0 license header. Before you open a PR, run `./gradlew :sdks:rust:check` to verify compliance. diff --git a/sdks/rust/beam/model/Cargo.toml b/sdks/rust/beam/model/Cargo.toml new file mode 100644 index 000000000000..d57b276819f2 --- /dev/null +++ b/sdks/rust/beam/model/Cargo.toml @@ -0,0 +1,47 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +[package] +name = "apache-beam-model" +version.workspace = true +edition.workspace = true +rust-version.workspace = true +license.workspace = true +repository.workspace = true +description = "Portability model definitions and gRPC bindings for Apache Beam in Rust" + +[lib] +name = "beam_model" +doctest = false +test = false + +[dependencies] +prost = { workspace = true } +prost-types = { workspace = true } +tonic = { workspace = true } +tonic-prost = { workspace = true } + +[build-dependencies] +tonic-prost-build = { workspace = true } + +# No [lints] workspace opt-in: this crate is entirely tonic/prost generated code. + +# These are used by the generated code `tonic::include_proto!` pulls in from OUT_DIR, +# which cargo-machete does not scan. +[package.metadata.cargo-machete] +ignored = ["prost", "prost-types", "tonic-prost"] + diff --git a/sdks/rust/beam/model/build.rs b/sdks/rust/beam/model/build.rs new file mode 100644 index 000000000000..c02b4a749740 --- /dev/null +++ b/sdks/rust/beam/model/build.rs @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +use std::path::{Path, PathBuf}; + +fn main() -> Result<(), Box> { + let manifest_dir = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR")?); + let root_dir = manifest_dir.join("../../../.."); + + let pipeline_proto_dir = root_dir.join("model/pipeline/src/main/proto"); + let fn_execution_proto_dir = root_dir.join("model/fn-execution/src/main/proto"); + let job_management_proto_dir = root_dir.join("model/job-management/src/main/proto"); + + let proto_sets: &[(&Path, &[&str])] = &[ + ( + &pipeline_proto_dir, + &[ + "org/apache/beam/model/pipeline/v1/endpoints.proto", + "org/apache/beam/model/pipeline/v1/schema.proto", + "org/apache/beam/model/pipeline/v1/metrics.proto", + "org/apache/beam/model/pipeline/v1/standard_window_fns.proto", + "org/apache/beam/model/pipeline/v1/beam_runner_api.proto", + "org/apache/beam/model/pipeline/v1/external_transforms.proto", + ], + ), + ( + &job_management_proto_dir, + &[ + "org/apache/beam/model/job_management/v1/beam_artifact_api.proto", + "org/apache/beam/model/job_management/v1/beam_expansion_api.proto", + "org/apache/beam/model/job_management/v1/beam_job_api.proto", + ], + ), + ( + &fn_execution_proto_dir, + &[ + "org/apache/beam/model/fn_execution/v1/beam_provision_api.proto", + "org/apache/beam/model/fn_execution/v1/beam_fn_api.proto", + ], + ), + ]; + + let protos: Vec = proto_sets + .iter() + .flat_map(|(dir, files)| files.iter().map(move |file| dir.join(file))) + .collect(); + + let includes = [ + pipeline_proto_dir, + fn_execution_proto_dir, + job_management_proto_dir, + ]; + + for proto in &protos { + println!("cargo:rerun-if-changed={}", proto.display()); + } + + tonic_prost_build::configure() + .build_server(true) + .build_client(true) + .compile_protos(&protos, &includes)?; + + Ok(()) +} diff --git a/sdks/rust/beam/model/src/lib.rs b/sdks/rust/beam/model/src/lib.rs new file mode 100644 index 000000000000..5888712aa8f1 --- /dev/null +++ b/sdks/rust/beam/model/src/lib.rs @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +//! Generated Protobuf and gRPC definitions for Apache Beam. + +#![allow(clippy::all)] +#![allow(unknown_lints)] +#![allow(unused_imports)] +#![allow(non_snake_case)] + +mod org { + pub mod apache { + pub mod beam { + pub mod model { + pub mod pipeline { + pub mod v1 { + tonic::include_proto!("org.apache.beam.model.pipeline.v1"); + } + } + pub mod fn_execution { + pub mod v1 { + tonic::include_proto!("org.apache.beam.model.fn_execution.v1"); + } + } + pub mod job_management { + pub mod v1 { + tonic::include_proto!("org.apache.beam.model.job_management.v1"); + } + } + pub mod expansion { + pub mod v1 { + tonic::include_proto!("org.apache.beam.model.expansion.v1"); + } + } + } + } + } +} + +// Short top-level paths to the versioned proto modules. +pub mod pipeline { + pub use crate::org::apache::beam::model::pipeline::v1::*; +} + +pub mod fn_execution { + pub use crate::org::apache::beam::model::fn_execution::v1::*; +} + +pub mod job_management { + pub use crate::org::apache::beam::model::job_management::v1::*; +} + +pub mod expansion { + pub use crate::org::apache::beam::model::expansion::v1::*; +} diff --git a/sdks/rust/build.gradle.kts b/sdks/rust/build.gradle.kts new file mode 100644 index 000000000000..43562b6070ac --- /dev/null +++ b/sdks/rust/build.gradle.kts @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// The Rust SDK. BeamRustPlugin in buildSrc defines the tasks (`./gradlew :sdks:rust:build`, +// `:check`, `:test`), and cargo does the work. + +plugins { id("org.apache.beam.rust") } + +description = "Apache Beam :: SDKs :: Rust" diff --git a/sdks/rust/clippy.toml b/sdks/rust/clippy.toml new file mode 100644 index 000000000000..08347764d983 --- /dev/null +++ b/sdks/rust/clippy.toml @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# `unwrap_used`, `expect_used` and `panic` target library, binary and example code. +# The Gradle `clippy` task allows them on `--tests --benches`, and these flags exempt `#[cfg(test)]`. +allow-unwrap-in-tests = true +allow-expect-in-tests = true +allow-panic-in-tests = true diff --git a/sdks/rust/docs/development.md b/sdks/rust/docs/development.md new file mode 100644 index 000000000000..bb5991b41300 --- /dev/null +++ b/sdks/rust/docs/development.md @@ -0,0 +1,93 @@ + + +# Developing the Rust SDK + +This page gives the build, test and lint tasks for developers of the +SDK itself. Pipeline authors do not need these tasks. See the [SDK README](../README.md). + +Run builds and tests through Gradle, like the rest of the Beam repository. The Gradle tasks call cargo, so a cargo command gives the same result: + +```bash +# Core Lifecycle Tasks +./gradlew :sdks:rust:build # Compile all crates in workspace +./gradlew :sdks:rust:check # Run formatting checks and clippy linter +./gradlew :sdks:rust:test # Run all tests (or -Ppkg=apache-beam-model) +./gradlew :sdks:rust:fmt # Apply code formatting (cargo fmt) +./gradlew :sdks:rust:clean # Remove the cargo target directory +``` + +## One way + +Every public API change follows these rules: + +- **No aliases or compatibility shims.** A rename removes the old name. The same + change updates every caller, example and doc. +- **One public path per item.** Pipeline items are in their module + (`transforms`, `transforms::sdf`, `windowing`, `coders`, ...). Runner and + harness plumbing (`BundleHandler`, `ElementSink`, `HandlerContext`, ...) is + only in `beam::internals`. The preludes are the only additional path. +- **Fluent methods mirror core transforms.** Each method is the snake_case name + of exactly one core transform (`.group_by_key` → `GroupByKey`). It adds no + semantics. Documented exception: `with_side_singleton` / `with_side_iter` / + `with_side_map`. Each of these is a `ParDo` with one side input. +- **Fluent covers common cases.** For advanced configuration, use + `.apply(name, Transform::new(..))`, which also chains. Do not add fluent variants + for advanced configuration. +- **Construction.** Build transforms with `new(required..)` and `.with_*()` + builders. The name of a transform is given at `apply(name, transform)`, not to + the constructor. Value types (e.g. `FixedWindows::of`) are exempt. +- **Errors.** User hooks (`DoFn`, `CombineFn`, state, timers) return `beam::Result`. +- **Prelude.** `beam::prelude` contains only the items that a typical pipeline author uses. + +## Comments and documentation + +Comments and rustdoc follow the writing rules of +[ASD-STE100 Simplified Technical English](https://www.asd-ste100.org/about_STE.html). +Beam, Rust and protocol terms are permitted technical names. + +- **Short sentences.** At most 20 words for an instruction and 25 words for a + description. One topic per sentence. +- **Active voice.** Write instructions in the imperative: "Call `finish` before + `drop`", "Do not share the sink". +- **One word, one meaning.** Use the same term for the same thing in all files. +- **Say what the code cannot.** Write a comment for a constraint, a contract or a + reason that is not clear from the code. Do not repeat what the code does. +- **No numbered steps.** If the order is important, say so in words or split the + code into functions. +- **No history.** Do not write "used to", "now", "previously", "no longer" or + "Regression:". Write the rule that is true for the current code. A test + comment states the behavior that the test checks. +- **This SDK only.** Do not compare with other SDKs ("like Java", "same as Go", + "the equivalent of"). Name another SDK only when the behavior depends on it: + a cross-language transform that the code calls, or a wire format, URN or + protocol rule that other SDKs must decode. Comparisons between SDKs go in + `DESIGN.md`. +- **Plain words.** Use the simplest word that is correct. Do not use: thus, hence, + therefore, obey, ensure, utilize, leverage, facilitate, via, prior to, + subsequent, terminate, approximately, sufficient, robust, seamless, + comprehensive, crucial, essential, simply, merely, basically, actually, + effectively, notably, furthermore, moreover, additionally, "in order to", + "note that", "stem from". Use so, follow, make sure, use, help, through, + before, then, stop, about, enough, also, to. +- **Short.** A comment is shorter than the code it explains. Fill lines to about + 90 columns: one short sentence does not need its own line. +- **Rustdoc.** Start with a one-line summary. Do not repeat the item name + ("Returns the key." on `fn key`). Add `# Errors`, `# Panics` or `# Safety` only + when the condition is not clear from the signature and the summary. diff --git a/sdks/rust/rustfmt.toml b/sdks/rust/rustfmt.toml new file mode 100644 index 000000000000..f89006ae7849 --- /dev/null +++ b/sdks/rust/rustfmt.toml @@ -0,0 +1,23 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +edition = "2024" +max_width = 100 +use_small_heuristics = "Default" +newline_style = "Unix" +reorder_imports = true +reorder_modules = true diff --git a/sdks/rust/scripts/set_version.sh b/sdks/rust/scripts/set_version.sh new file mode 100755 index 000000000000..824722326665 --- /dev/null +++ b/sdks/rust/scripts/set_version.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Sets the version of every crate in the Rust SDK workspace. +# +# Usage: set_version.sh +# +# Called by release/src/main/scripts/set_version.sh with a release version +# (X.Y.Z) or a snapshot version (X.Y.Z-SNAPSHOT). Cargo requires semver, so +# snapshots use a -SNAPSHOT pre-release suffix. +# +# Updates: +# - [workspace.package] version in Cargo.toml, +# - the version on every internal path dependency in any Cargo.toml, +# - workspace member entries in Cargo.lock ([[package]] blocks without a +# `source`), so `--locked` builds work without running cargo. + +set -euo pipefail + +if [[ $# -ne 1 || -z "$1" ]]; then + echo "Usage: $0 " >&2 + exit 1 +fi + +VERSION="$1" +RUST_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" + +# Writes the output of a filter over a file back to that file. +rewrite() { + local file="$1" + shift + "$@" < "$file" > "$file.tmp" + mv "$file.tmp" "$file" +} + +find "$RUST_ROOT" -name Cargo.toml -not -path '*/target/*' -not -path '*/build/*' -print \ + | while IFS= read -r manifest; do + rewrite "$manifest" sed -E \ + -e "s/^version = \"[^\"]*\"$/version = \"$VERSION\"/" \ + -e "/path = \"/s/version = \"[^\"]*\"/version = \"$VERSION\"/" + done + +rewrite "$RUST_ROOT/Cargo.lock" awk -v version="$VERSION" ' + BEGIN { RS = "" } + /^\[\[package\]\]/ && !/\nsource = / { + sub(/\nversion = "[^"]*"/, "\nversion = \"" version "\"") + } + { printf "%s%s", (NR > 1 ? "\n\n" : ""), $0 } + END { print "" } +' diff --git a/settings.gradle.kts b/settings.gradle.kts index 0d16eb1db1ca..861baae9da4f 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -350,6 +350,7 @@ include(":sdks:python:test-suites:tox:py314") include(":sdks:python:test-suites:xlang") include(":sdks:typescript") include(":sdks:typescript:container") +include(":sdks:rust") include(":vendor:grpc-1_69_0") include(":vendor:calcite-1_40_0") include(":vendor:guava-32_1_2-jre")