Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5ea2952

Browse files
authored
codegen: add Options() method to read copied client config (#482)
1 parent3280c19 commit5ea2952

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"id":"966e9ee6-2f38-4f2a-a660-c8bac175addb",
3+
"type":"feature",
4+
"description":"Expose Options() method on generated service clients.",
5+
"modules": [
6+
"."
7+
]
8+
}

‎codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/GoWriter.java‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,23 @@ public static Writable goDocTemplate(String contents) {
152152
returngoDocTemplate(contents,newHashMap<>());
153153
}
154154

155+
/**
156+
* Auto-formats a multi-paragraph string as a doc writable (including line wrapping).
157+
* @param contents The docs.
158+
* @return writer for formatted docs.
159+
*/
160+
publicstaticWritableautoDocTemplate(Stringcontents) {
161+
returnGoWriter.ChainWritable.of(
162+
Arrays.stream(contents.split("\n\n"))
163+
.map(it ->docParagraphWriter(it.replace("\n"," ")))
164+
.toList()
165+
).compose(false);
166+
}
167+
168+
privatestaticGoWriter.WritabledocParagraphWriter(Stringparagraph) {
169+
returnwriter ->writer.writeDocs(paragraph).writeDocs("");
170+
}
171+
155172
@SafeVarargs
156173
publicstaticWritablegoDocTemplate(Stringcontents,Map<String,Object>...args) {
157174
validateTemplateArgsNotNull(args);

‎codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/ServiceGenerator.java‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
packagesoftware.amazon.smithy.go.codegen;
1717

18+
importstaticsoftware.amazon.smithy.go.codegen.GoWriter.autoDocTemplate;
1819
importstaticsoftware.amazon.smithy.go.codegen.GoWriter.emptyGoTemplate;
1920
importstaticsoftware.amazon.smithy.go.codegen.GoWriter.goDocTemplate;
2021
importstaticsoftware.amazon.smithy.go.codegen.GoWriter.goTemplate;
@@ -95,6 +96,7 @@ private GoWriter.Writable generate() {
9596
generateMetadata(),
9697
generateClient(),
9798
generateNew(),
99+
generateGetOptions(),
98100
generateInvokeOperation(),
99101
generateInputContextFuncs(),
100102
generateAddProtocolFinalizerMiddleware()
@@ -223,6 +225,20 @@ func New(options $options:L, optFns ...func(*$options:L)) *$client:L {
223225
));
224226
}
225227

228+
privateGoWriter.WritablegenerateGetOptions() {
229+
vardocs =autoDocTemplate("""
230+
Options returns a copy of the client configuration.
231+
232+
Callers SHOULD NOT perform mutations on any inner structures within client config. Config overrides
233+
should instead be made on a per-operation basis through functional options.""");
234+
returngoTemplate("""
235+
$W
236+
func (c $P) Options() $L {
237+
return c.options.Copy()
238+
}
239+
""",docs,symbolProvider.toSymbol(service),ClientOptions.NAME);
240+
}
241+
226242
privateGoWriter.WritablegenerateConfigFieldResolver(ConfigFieldResolverresolver) {
227243
returnwriter -> {
228244
writer.writeInline("$T(&options",resolver.getResolver());

‎endpoints/private/rulesfn/strings.go‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package rulesfn
22

3-
43
// Substring returns the substring of the input provided. If the start or stop
54
// indexes are not valid for the input nil will be returned. If errors occur
65
// they will be added to the provided [ErrorCollector].

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp