Skip to content

Commit

Permalink
service -> server per smithy naming recs
Browse files Browse the repository at this point in the history
  • Loading branch information
lucix-aws committed Feb 26, 2024
1 parent e42814f commit 979b66b
Show file tree
Hide file tree
Showing 18 changed files with 63 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import software.amazon.smithy.go.codegen.GoSettings.ArtifactType;
import software.amazon.smithy.go.codegen.GoWriter;
import software.amazon.smithy.go.codegen.TriConsumer;
import software.amazon.smithy.go.codegen.service.ServiceProtocolGenerator;
import software.amazon.smithy.go.codegen.server.ServerProtocolGenerator;
import software.amazon.smithy.model.Model;
import software.amazon.smithy.model.shapes.ServiceShape;
import software.amazon.smithy.model.shapes.Shape;
Expand Down Expand Up @@ -167,7 +167,7 @@ default List<ProtocolGenerator> getProtocolGenerators() {
* Gets a list of server protocol generators to register. Protocol generators should generally be written to accept
* the codegen context at construction time, such that all the model information necessary for codegen is available.
*/
default List<ServiceProtocolGenerator> getServerProtocolGenerators(GoCodegenContext ctx) {
default List<ServerProtocolGenerator> getServerProtocolGenerators(GoCodegenContext ctx) {
return Collections.emptyList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* permissions and limitations under the License.
*/

package software.amazon.smithy.go.codegen.service;
package software.amazon.smithy.go.codegen.server;

import static software.amazon.smithy.go.codegen.GoWriter.goTemplate;

Expand Down Expand Up @@ -62,15 +62,15 @@ private GoWriter.Writable generateStruct() {
""",
MapUtils.of(
"struct", NAME,
"interface", ServiceInterface.NAME,
"interface", ServerInterface.NAME,
"operations", generateOperations()
));
}

private GoWriter.Writable generateOperations() {
return GoWriter.ChainWritable.of(
TopDownIndex.of(model).getContainedOperations(service).stream()
.filter(op -> !ServiceCodegenUtils.operationHasEventStream(
.filter(op -> !ServerCodegenUtil.operationHasEventStream(
model, operationIndex.expectInputShape(op), operationIndex.expectOutputShape(op)))
.map(this::generateOperation)
.toList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* permissions and limitations under the License.
*/

package software.amazon.smithy.go.codegen.service;
package software.amazon.smithy.go.codegen.server;

import static software.amazon.smithy.go.codegen.GoWriter.goTemplate;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* permissions and limitations under the License.
*/

package software.amazon.smithy.go.codegen.service;
package software.amazon.smithy.go.codegen.server;

import static software.amazon.smithy.go.codegen.GoWriter.goTemplate;

Expand All @@ -25,9 +25,9 @@
public final class OptionsStruct implements GoWriter.Writable {
public static final String NAME = "Options";

private final ServiceProtocolGenerator protocolGenerator;
private final ServerProtocolGenerator protocolGenerator;

public OptionsStruct(ServiceProtocolGenerator protocolGenerator) {
public OptionsStruct(ServerProtocolGenerator protocolGenerator) {
this.protocolGenerator = protocolGenerator;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* permissions and limitations under the License.
*/

package software.amazon.smithy.go.codegen.service;
package software.amazon.smithy.go.codegen.server;

import static software.amazon.smithy.go.codegen.GoWriter.goTemplate;

Expand All @@ -29,9 +29,9 @@
public final class RequestHandler implements GoWriter.Writable {
public static final String NAME = "RequestHandler";

private final ServiceProtocolGenerator protocolGenerator;
private final ServerProtocolGenerator protocolGenerator;

public RequestHandler(ServiceProtocolGenerator protocolGenerator) {
public RequestHandler(ServerProtocolGenerator protocolGenerator) {
this.protocolGenerator = protocolGenerator;
}

Expand All @@ -57,7 +57,7 @@ private GoWriter.Writable generateStruct() {
""",
MapUtils.of(
"this", NAME,
"service", ServiceInterface.NAME,
"service", ServerInterface.NAME,
"options", OptionsStruct.NAME
));
}
Expand All @@ -80,7 +80,7 @@ func New(svc $interface:L, opts $options:L, optFns ...func(*$options:L)) *$this:
""",
MapUtils.of(
"this", NAME,
"interface", ServiceInterface.NAME,
"interface", ServerInterface.NAME,
"options", OptionsStruct.NAME
));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* permissions and limitations under the License.
*/

package software.amazon.smithy.go.codegen.service;
package software.amazon.smithy.go.codegen.server;

import java.util.logging.Logger;
import software.amazon.smithy.build.PluginContext;
Expand All @@ -29,8 +29,8 @@
* Plugin to trigger Go server code generation.
*/
@SmithyInternalApi
public final class ServiceCodegenPlugin implements SmithyBuildPlugin {
private static final Logger LOGGER = Logger.getLogger(ServiceCodegenPlugin.class.getName());
public final class ServerCodegenPlugin implements SmithyBuildPlugin {
private static final Logger LOGGER = Logger.getLogger(ServerCodegenPlugin.class.getName());

@Override
public String getName() {
Expand Down Expand Up @@ -67,7 +67,7 @@ private void generate(PluginContext context) {
GoSettings> runner = new CodegenDirector<>();

runner.model(context.getModel());
runner.directedCodegen(new ServiceDirectedCodegen());
runner.directedCodegen(new ServerDirectedCodegen());

runner.integrationClass(GoIntegration.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* permissions and limitations under the License.
*/

package software.amazon.smithy.go.codegen.service;
package software.amazon.smithy.go.codegen.server;

import static java.util.stream.Collectors.toSet;

Expand All @@ -39,8 +39,8 @@
import software.amazon.smithy.utils.SmithyInternalApi;

@SmithyInternalApi
public final class ServiceCodegenUtils {
private ServiceCodegenUtils() {}
public final class ServerCodegenUtil {
private ServerCodegenUtil() {}

public static boolean operationHasEventStream(
Model model,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
* permissions and limitations under the License.
*/

package software.amazon.smithy.go.codegen.service;
package software.amazon.smithy.go.codegen.server;

import static java.util.stream.Collectors.toSet;
import static software.amazon.smithy.go.codegen.GoWriter.goTemplate;
import static software.amazon.smithy.go.codegen.service.ServiceCodegenUtils.getShapesToSerde;
import static software.amazon.smithy.go.codegen.service.ServiceCodegenUtils.isUnit;
import static software.amazon.smithy.go.codegen.service.ServiceCodegenUtils.withUnit;
import static software.amazon.smithy.go.codegen.server.ServerCodegenUtil.getShapesToSerde;
import static software.amazon.smithy.go.codegen.server.ServerCodegenUtil.isUnit;
import static software.amazon.smithy.go.codegen.server.ServerCodegenUtil.withUnit;

import java.util.List;
import software.amazon.smithy.codegen.core.CodegenException;
Expand Down Expand Up @@ -57,7 +57,7 @@
import software.amazon.smithy.utils.SmithyInternalApi;

@SmithyInternalApi
public class ServiceDirectedCodegen implements DirectedCodegen<GoCodegenContext, GoSettings, GoIntegration> {
public class ServerDirectedCodegen implements DirectedCodegen<GoCodegenContext, GoSettings, GoIntegration> {
@Override
public SymbolProvider createSymbolProvider(CreateSymbolProviderDirective<GoSettings> directive) {
return new SymbolVisitor(withUnit(directive.model()), directive.settings());
Expand Down Expand Up @@ -97,7 +97,7 @@ public void generateService(GenerateServiceDirective<GoCodegenContext, GoSetting

delegator.useFileWriter("service.go", namespace, GoWriter.ChainWritable.of(
new NotImplementedError(),
new ServiceInterface(directive.model(), directive.service(), directive.symbolProvider()),
new ServerInterface(directive.model(), directive.service(), directive.symbolProvider()),
new NoopServiceStruct(directive.model(), directive.service(), directive.symbolProvider()),
new RequestHandler(protocolGenerator)
).compose());
Expand All @@ -109,7 +109,7 @@ public void generateService(GenerateServiceDirective<GoCodegenContext, GoSetting
delegator.useFileWriter("serialize.go", namespace,
protocolGenerator.generateSerializers(shapesToSerialize));
delegator.useFileWriter("validate.go", namespace,
new ServiceValidationGenerator().generate(model, service, directive.symbolProvider()));
new ServerValidationgenerator().generate(model, service, directive.symbolProvider()));
delegator.useFileWriter("protocol.go", namespace,
protocolGenerator.generateProtocolSource());

Expand Down Expand Up @@ -198,7 +198,7 @@ public void generateIntEnumShape(GenerateIntEnumDirective<GoCodegenContext, GoSe
);
}

private ServiceProtocolGenerator resolveProtocolGenerator(GoCodegenContext ctx) {
private ServerProtocolGenerator resolveProtocolGenerator(GoCodegenContext ctx) {
var model = ctx.model();
var service = ctx.settings().getService(model);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* permissions and limitations under the License.
*/

package software.amazon.smithy.go.codegen.service;
package software.amazon.smithy.go.codegen.server;

import static software.amazon.smithy.go.codegen.GoWriter.goTemplate;

Expand All @@ -30,15 +30,15 @@
/**
* Generates the interface that describes the service API.
*/
public final class ServiceInterface implements GoWriter.Writable {
public final class ServerInterface implements GoWriter.Writable {
public static final String NAME = "Service";

private final Model model;
private final ServiceShape service;
private final SymbolProvider symbolProvider;
private final OperationIndex operationIndex;

public ServiceInterface(Model model, ServiceShape service, SymbolProvider symbolProvider) {
public ServerInterface(Model model, ServiceShape service, SymbolProvider symbolProvider) {
this.model = model;
this.service = service;
this.symbolProvider = symbolProvider;
Expand All @@ -62,7 +62,7 @@ private GoWriter.Writable generateInterface() {
private GoWriter.Writable generateOperations() {
return GoWriter.ChainWritable.of(
TopDownIndex.of(model).getContainedOperations(service).stream()
.filter(op -> !ServiceCodegenUtils.operationHasEventStream(
.filter(op -> !ServerCodegenUtil.operationHasEventStream(
model, operationIndex.expectInputShape(op), operationIndex.expectOutputShape(op)))
.map(this::generateOperation)
.toList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* permissions and limitations under the License.
*/

package software.amazon.smithy.go.codegen.service;
package software.amazon.smithy.go.codegen.server;

import java.util.Set;
import software.amazon.smithy.go.codegen.ApplicationProtocol;
Expand All @@ -24,7 +24,7 @@
import software.amazon.smithy.utils.SmithyInternalApi;

@SmithyInternalApi
public interface ServiceProtocolGenerator {
public interface ServerProtocolGenerator {
// Smithy
ApplicationProtocol getApplicationProtocol();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* permissions and limitations under the License.
*/

package software.amazon.smithy.go.codegen.service;
package software.amazon.smithy.go.codegen.server;

import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -59,7 +59,7 @@
import software.amazon.smithy.utils.StringUtils;

@SmithyInternalApi
public final class ServiceValidationGenerator {
public final class ServerValidationgenerator {
public GoWriter.Writable generate(Model model, ServiceShape service, SymbolProvider symbolProvider) {
return writer -> execute(writer, model, symbolProvider, service);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
* permissions and limitations under the License.
*/

package software.amazon.smithy.go.codegen.service.integration;
package software.amazon.smithy.go.codegen.server.integration;

import java.util.List;
import software.amazon.smithy.go.codegen.GoCodegenContext;
import software.amazon.smithy.go.codegen.GoSettings;
import software.amazon.smithy.go.codegen.integration.GoIntegration;
import software.amazon.smithy.go.codegen.service.ServiceProtocolGenerator;
import software.amazon.smithy.go.codegen.service.protocol.aws.AwsJson10ProtocolGenerator;
import software.amazon.smithy.go.codegen.server.ServerProtocolGenerator;
import software.amazon.smithy.go.codegen.server.protocol.aws.AwsJson10ProtocolGenerator;
import software.amazon.smithy.utils.ListUtils;
import software.amazon.smithy.utils.SmithyInternalApi;

Expand All @@ -32,7 +32,7 @@ public GoSettings.ArtifactType getArtifactType() {
}

@Override
public List<ServiceProtocolGenerator> getServerProtocolGenerators(GoCodegenContext ctx) {
public List<ServerProtocolGenerator> getServerProtocolGenerators(GoCodegenContext ctx) {
return ListUtils.of(
new AwsJson10ProtocolGenerator(ctx)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* permissions and limitations under the License.
*/

package software.amazon.smithy.go.codegen.service.protocol;
package software.amazon.smithy.go.codegen.server.protocol;

import static software.amazon.smithy.go.codegen.GoWriter.emptyGoTemplate;
import static software.amazon.smithy.go.codegen.GoWriter.goTemplate;
Expand All @@ -24,9 +24,9 @@
import software.amazon.smithy.go.codegen.GoWriter;
import software.amazon.smithy.go.codegen.SmithyGoTypes;
import software.amazon.smithy.go.codegen.knowledge.GoValidationIndex;
import software.amazon.smithy.go.codegen.service.RequestHandler;
import software.amazon.smithy.go.codegen.service.ServiceProtocolGenerator;
import software.amazon.smithy.go.codegen.service.ServiceValidationGenerator;
import software.amazon.smithy.go.codegen.server.RequestHandler;
import software.amazon.smithy.go.codegen.server.ServerProtocolGenerator;
import software.amazon.smithy.go.codegen.server.ServerValidationgenerator;
import software.amazon.smithy.model.shapes.OperationShape;
import software.amazon.smithy.model.shapes.Shape;
import software.amazon.smithy.utils.MapUtils;
Expand All @@ -37,7 +37,7 @@
* HTTP protocols serve requests by generating a net/http.Handler implementation onto the base RequestHandler struct.
*/
@SmithyInternalApi
public abstract class HttpHandlerProtocolGenerator implements ServiceProtocolGenerator {
public abstract class HttpHandlerProtocolGenerator implements ServerProtocolGenerator {
protected final GoCodegenContext ctx;

private final GoValidationIndex validationIndex;
Expand Down Expand Up @@ -185,7 +185,7 @@ private GoWriter.Writable generateValidateInput(Shape input) {
serializeError(w, err)
return
}
""", ServiceValidationGenerator.getShapeValidatorName(input));
""", ServerValidationgenerator.getShapeValidatorName(input));
}

private GoWriter.Writable generateInvokeInterceptor(String type, String args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
* permissions and limitations under the License.
*/

package software.amazon.smithy.go.codegen.service.protocol;
package software.amazon.smithy.go.codegen.server.protocol;

import static software.amazon.smithy.go.codegen.GoWriter.goTemplate;
import static software.amazon.smithy.go.codegen.SymbolUtils.getReference;
import static software.amazon.smithy.go.codegen.SymbolUtils.isPointable;
import static software.amazon.smithy.go.codegen.service.ServiceCodegenUtils.normalize;
import static software.amazon.smithy.go.codegen.server.ServerCodegenUtil.normalize;

import java.util.Set;
import software.amazon.smithy.codegen.core.CodegenException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
* permissions and limitations under the License.
*/

package software.amazon.smithy.go.codegen.service.protocol;
package software.amazon.smithy.go.codegen.server.protocol;

import static software.amazon.smithy.go.codegen.GoWriter.goTemplate;
import static software.amazon.smithy.go.codegen.SymbolUtils.getReference;
import static software.amazon.smithy.go.codegen.SymbolUtils.isPointable;
import static software.amazon.smithy.go.codegen.service.ServiceCodegenUtils.normalize;
import static software.amazon.smithy.go.codegen.server.ServerCodegenUtil.normalize;

import java.util.Set;
import software.amazon.smithy.codegen.core.CodegenException;
Expand Down
Loading

0 comments on commit 979b66b

Please sign in to comment.