Skip to content

Commit e46adc5

Browse files
authored
Support for HTTP2 for target .NET 8 and above (#3730)
1 parent db805ae commit e46adc5

File tree

82 files changed

+9995
-1922
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+9995
-1922
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"core": {
3+
"changeLogMessages": [
4+
"Add core support for bi directional HTTP 2 service operations. Support is only available in .NET 8 and later.",
5+
"[Breaking Change] Move IEventStreamEvent to Amazon.Runtime.EventStreams namespace from Amazon.Runtime.EventStreams.Internal",
6+
"[Breaking Change] Renamed IEventStream to IEventOutputStream and IEnumerableEventStream to IEnumerableEventOutputStream"
7+
],
8+
"type": "minor",
9+
"updateMinimum": true
10+
},
11+
"services": [
12+
{
13+
"serviceName": "TranscribeStreaming",
14+
"type": "minor",
15+
"changeLogMessages": [
16+
"Initial release of the TranscribeStreaming service package."
17+
]
18+
},
19+
{
20+
"serviceName": "Kinesis",
21+
"type": "minor",
22+
"changeLogMessages": [
23+
"Add the bi-directional streaming operation SubscribeToShard."
24+
]
25+
},
26+
{
27+
"serviceName": "QBusiness",
28+
"type": "minor",
29+
"changeLogMessages": [
30+
"Add the bi-directional streaming operation Chat."
31+
]
32+
},
33+
{
34+
"serviceName": "LexRuntimeV2",
35+
"type": "minor",
36+
"changeLogMessages": [
37+
"Add the bi-directional streaming operation StartConversation."
38+
]
39+
}
40+
]
41+
}

generator/ServiceClientGeneratorLib/GeneratorDriver.cs

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,6 @@ public GeneratorDriver(ServiceConfiguration config, GenerationManifest generatio
139139

140140
public void Execute()
141141
{
142-
if (Configuration.ServiceModel.H2Support == H2SupportDegree.Required)
143-
{
144-
Console.WriteLine("This service requires HTTP2 for all operations. The AWS SDK for .NET does not yet support this functionality. Not generating service.");
145-
return;
146-
}
147-
148142
ValidateServiceModel();
149143

150144
this.FilesWrittenToGeneratorFolder.Clear();
@@ -248,6 +242,7 @@ public void Execute()
248242
GenerateEndpointDiscoveryMarshaller(operation);
249243
GenerateExceptions(operation);
250244
GenerateStructures(operation);
245+
GenerateEventStreamPublisher(operation);
251246
}
252247

253248
if (Configuration.ServiceModel.Customizations.GenerateCustomUnmarshaller)
@@ -300,6 +295,45 @@ void GenerateRequest(Operation operation)
300295
this.DetermineStructuresToProcess(operation.RequestStructure, false);
301296
}
302297

298+
void GenerateEventStreamPublisher(Operation operation)
299+
{
300+
var eventStreamStructure = operation.RequestEventStreamingMember?.Shape;
301+
if (eventStreamStructure == null)
302+
return;
303+
304+
var publisherMarshaller = new EventStreamPublisherMarshaller
305+
{
306+
ClassName = eventStreamStructure.Name + "PublisherMarshaller",
307+
Structure = eventStreamStructure
308+
};
309+
310+
this.ExecuteGenerator(publisherMarshaller, publisherMarshaller.ClassName + ".cs", "Model.Internal.MarshallTransformations");
311+
312+
var evntTypes = new List<string>();
313+
foreach (var member in eventStreamStructure.Members)
314+
{
315+
if (member.Shape.IsEvent)
316+
{
317+
evntTypes.Add(member.Shape.Name);
318+
var addIntefaceImpementationGenerator = new EventCollectionAddImplementation
319+
{
320+
InterfaceName = "I" + eventStreamStructure.Name + "Event",
321+
ClassName = member.Shape.Name
322+
};
323+
this.ExecuteGenerator(addIntefaceImpementationGenerator, member.Shape.Name + "." + addIntefaceImpementationGenerator.InterfaceName + ".cs", "Model");
324+
}
325+
}
326+
327+
var eventCollectionInterface = new EventCollectionInterface()
328+
{
329+
InterfaceName = "I" + eventStreamStructure.Name + "Event",
330+
OperationName = operation.Name,
331+
EvntTypes = evntTypes
332+
};
333+
334+
this.ExecuteGenerator(eventCollectionInterface, eventCollectionInterface.InterfaceName + ".cs", "Model");
335+
}
336+
303337
private void ValidateServiceModel()
304338
{
305339
// Check to see if any of the GET operations have invalid request body members.
@@ -545,7 +579,7 @@ void GenerateRequestMarshaller(Operation operation)
545579
if (nestedStructure.IsDocument)
546580
continue;
547581

548-
if (!this._processedMarshallers.Contains(nestedStructure.Name))
582+
if (!this._processedMarshallers.Contains(nestedStructure.Name) && !nestedStructure.IsEventStream)
549583
{
550584
var structureGenerator = GetStructureMarshaller();
551585
structureGenerator.Structure = nestedStructure;
@@ -734,7 +768,7 @@ void GenerateEndpointDiscoveryMarshaller(Operation operation)
734768
private void GenerateExceptions(Operation operation)
735769
{
736770
//Generate a special EventStreamException class that extends EventStreamException
737-
//We need a parameterless constructor to use it in EnumerableEventStream. Only once per service
771+
//We need a parameterless constructor to use it in EnumerableEventOutputStream. Only once per service
738772
if (operation.IsEventStreamOutput && !Configuration.GeneratedEventStreamException)
739773
{
740774
var eventStreamExceptionGenerator = new EventStreamExceptionGenerator();
@@ -964,6 +998,10 @@ void GenerateStructures(Operation operation)
964998
if (IsShapePresentInParentModel(this.Configuration, definition.Name))
965999
continue;
9661000

1001+
// Skip structures that are only used as input event streams. Those structures are handled separately as part of the GenerateEventStreamPublisher method.
1002+
if (definition.IsEventStream && !Configuration.ServiceModel.Operations.Any(x => string.Equals(x.ResponseEventStreamingMember?.Shape.Name, definition.Name)))
1003+
continue;
1004+
9671005
if (!this._processedStructures.Contains(definition.Name))
9681006
{
9691007
// if the shape had a substitution, we can skip generation
@@ -1001,7 +1039,6 @@ void GenerateStructures(Operation operation)
10011039

10021040
this.ExecuteGenerator(generator, definition.Name + ".cs", "Model");
10031041
this._processedStructures.Add(definition.Name);
1004-
10051042
}
10061043
}
10071044
}

0 commit comments

Comments
 (0)