Skip to content

Commit

Permalink
Add clientless endpoint - fix references and update license to 2020 (#…
Browse files Browse the repository at this point in the history
…679)

* Refactor, cleanup serverless endpoint

* Fix license template for 2020
  • Loading branch information
tejaswiagarwal committed Jan 4, 2020
1 parent ede49fa commit e668e50
Show file tree
Hide file tree
Showing 128 changed files with 167 additions and 171 deletions.
2 changes: 1 addition & 1 deletion benchmarks/benchserver/main.go
@@ -1,4 +1,4 @@
// Copyright (c) 2019 Uber Technologies, Inc.
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/runner/main.go
@@ -1,4 +1,4 @@
// Copyright (c) 2019 Uber Technologies, Inc.
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion codegen/casing.go
@@ -1,4 +1,4 @@
// Copyright (c) 2019 Uber Technologies, Inc.
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion codegen/casing_test.go
@@ -1,4 +1,4 @@
// Copyright (c) 2019 Uber Technologies, Inc.
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion codegen/client.go
@@ -1,4 +1,4 @@
// Copyright (c) 2019 Uber Technologies, Inc.
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion codegen/client_test.go
@@ -1,4 +1,4 @@
// Copyright (c) 2019 Uber Technologies, Inc.
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
42 changes: 21 additions & 21 deletions codegen/gateway.go
@@ -1,4 +1,4 @@
// Copyright (c) 2019 Uber Technologies, Inc.
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -279,8 +279,8 @@ type EndpointSpec struct {
ClientMethod string `yaml:"clientMethod,omitempty"`
// The client for this endpoint if httpClient or tchannelClient
ClientSpec *ClientSpec `yaml:"-"`
// DummyEndpoint checks if the endpoint is clientless
IsDummyEndpoint bool `yaml:"-"`
// IsClientlessEndpoint checks if the endpoint is clientless
IsClientlessEndpoint bool `yaml:"-"`
}

func ensureFields(config map[string]interface{}, mandatoryFields []string, yamlFile string) error {
Expand Down Expand Up @@ -352,7 +352,7 @@ func NewEndpointSpec(
var workflowImportPath string
var clientID string
var clientMethod string
var isDummyEndpoint bool
var isClientlessEndpoint bool

workflowType := endpointConfigObj["workflowType"].(string)
if workflowType == "httpClient" || workflowType == "tchannelClient" {
Expand Down Expand Up @@ -384,7 +384,7 @@ func NewEndpointSpec(
}
workflowImportPath = iworkflowImportPath.(string)
} else if workflowType == clientlessWorkflow {
isDummyEndpoint = true
isClientlessEndpoint = true
} else {
return nil, errors.Errorf(
"Invalid workflowType %q for endpoint %q",
Expand Down Expand Up @@ -417,22 +417,22 @@ func NewEndpointSpec(
}

espec := &EndpointSpec{
ModuleSpec: mspec,
YAMLFile: yamlFile,
GoStructsFileName: goStructsFileName,
GoFolderName: goFolderName,
GoPackageName: goPackageName,
EndpointType: endpointConfigObj["endpointType"].(string),
EndpointID: endpointConfigObj["endpointId"].(string),
HandleID: endpointConfigObj["handleId"].(string),
ThriftFile: thriftFile,
ThriftServiceName: parts[0],
ThriftMethodName: parts[1],
WorkflowType: workflowType,
WorkflowImportPath: workflowImportPath,
IsDummyEndpoint: isDummyEndpoint,
ClientID: clientID,
ClientMethod: clientMethod,
ModuleSpec: mspec,
YAMLFile: yamlFile,
GoStructsFileName: goStructsFileName,
GoFolderName: goFolderName,
GoPackageName: goPackageName,
EndpointType: endpointConfigObj["endpointType"].(string),
EndpointID: endpointConfigObj["endpointId"].(string),
HandleID: endpointConfigObj["handleId"].(string),
ThriftFile: thriftFile,
ThriftServiceName: parts[0],
ThriftMethodName: parts[1],
WorkflowType: workflowType,
WorkflowImportPath: workflowImportPath,
IsClientlessEndpoint: isClientlessEndpoint,
ClientID: clientID,
ClientMethod: clientMethod,
}

defaultMidSpecs, err := getOrderedDefaultMiddlewareSpecs(
Expand Down
2 changes: 1 addition & 1 deletion codegen/gateway_test.go
@@ -1,4 +1,4 @@
// Copyright (c) 2019 Uber Technologies, Inc.
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion codegen/header_propagate.go
@@ -1,4 +1,4 @@
// Copyright (c) 2019 Uber Technologies, Inc.
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion codegen/header_propagate_test.go
@@ -1,4 +1,4 @@
// Copyright (c) 2019 Uber Technologies, Inc.
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
20 changes: 10 additions & 10 deletions codegen/method.go
@@ -1,4 +1,4 @@
// Copyright (c) 2019 Uber Technologies, Inc.
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -137,8 +137,8 @@ type MethodSpec struct {
// Statements for converting response types
ConvertResponseGoStatements []string

// Statements for converting Dummy request types
ConvertDummyRequestGoStatements []string
// Statements for converting Clientless request types
ConvertClientlessRequestGoStatements []string

// Statements for propagating headers to client requests
PropagateHeadersGoStatements []string
Expand Down Expand Up @@ -1003,7 +1003,7 @@ func (ms *MethodSpec) setTypeConverters(
return nil
}

func (ms *MethodSpec) setDummyTypeConverters(
func (ms *MethodSpec) setClientlessTypeConverters(
funcSpec *compile.FunctionSpec,
reqTransforms map[string]FieldMapperEntry,
headersPropagate map[string]FieldMapperEntry,
Expand All @@ -1012,11 +1012,11 @@ func (ms *MethodSpec) setDummyTypeConverters(
h *PackageHelper,
) error {

dummyConverter := NewTypeConverter(h, nil)
clientlessConverter := NewTypeConverter(h, nil)

respType := funcSpec.ResultSpec.ReturnType

dummyConverter.append(
clientlessConverter.append(
"func convert",
PascalCase(ms.Name),
"DummyResponse(in ", ms.RequestType, ") ", ms.ResponseType, "{")
Expand Down Expand Up @@ -1044,16 +1044,16 @@ func (ms *MethodSpec) setDummyTypeConverters(
default:
// default as struct
respFields := respType.(*compile.StructSpec).Fields
dummyConverter.append("out", " := ", "&", ms.ShortResponseType, "{}\t\n")
err := dummyConverter.GenStructConverter(structType, respFields, dummyReqTransforms)
clientlessConverter.append("out", " := ", "&", ms.ShortResponseType, "{}\t\n")
err := clientlessConverter.GenStructConverter(structType, respFields, dummyReqTransforms)
if err != nil {
return err
}

}

dummyConverter.append("\nreturn out \t}")
ms.ConvertDummyRequestGoStatements = dummyConverter.GetLines()
clientlessConverter.append("\nreturn out \t}")
ms.ConvertClientlessRequestGoStatements = clientlessConverter.GetLines()

return nil
}
Expand Down
2 changes: 1 addition & 1 deletion codegen/mockgen.go
@@ -1,4 +1,4 @@
// Copyright (c) 2019 Uber Technologies, Inc.
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion codegen/module.go
@@ -1,4 +1,4 @@
// Copyright (c) 2019 Uber Technologies, Inc.
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
8 changes: 4 additions & 4 deletions codegen/module_system.go
@@ -1,4 +1,4 @@
// Copyright (c) 2019 Uber Technologies, Inc.
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -44,7 +44,7 @@ type EndpointMeta struct {
ClientMethodName string
WorkflowPkg string
ReqHeaders map[string]*TypedHeader
IsDummyEndpoint bool
IsClientlessEndpoint bool
ReqHeadersKeys []string
ReqRequiredHeadersKeys []string
ResHeaders map[string]*TypedHeader
Expand Down Expand Up @@ -1154,7 +1154,7 @@ func (g *EndpointGenerator) generateEndpointFile(
IncludedPackages: includedPackages,
Method: method,
ReqHeaders: reqHeaders,
IsDummyEndpoint: e.IsDummyEndpoint,
IsClientlessEndpoint: e.IsClientlessEndpoint,
ReqHeadersKeys: sortedHeaders(reqHeaders, false),
ReqRequiredHeadersKeys: sortedHeaders(reqHeaders, true),
ResHeadersKeys: sortedHeaders(e.ResHeaders, false),
Expand Down Expand Up @@ -1193,7 +1193,7 @@ func (g *EndpointGenerator) generateEndpointFile(
out[endpointFilePath] = endpoint

tmpl := ""
if e.IsDummyEndpoint {
if e.IsClientlessEndpoint {
tmpl = "clientless-workflow.tmpl"
} else {
tmpl = "workflow.tmpl"
Expand Down
2 changes: 1 addition & 1 deletion codegen/module_test.go
@@ -1,4 +1,4 @@
// Copyright (c) 2019 Uber Technologies, Inc.
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion codegen/package.go
@@ -1,4 +1,4 @@
// Copyright (c) 2019 Uber Technologies, Inc.
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion codegen/package_test.go
@@ -1,4 +1,4 @@
// Copyright (c) 2019 Uber Technologies, Inc.
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion codegen/post_gen_hooks.go
@@ -1,4 +1,4 @@
// Copyright (c) 2019 Uber Technologies, Inc.
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion codegen/proto.go
@@ -1,4 +1,4 @@
// Copyright (c) 2019 Uber Technologies, Inc.
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion codegen/proto_test.go
@@ -1,4 +1,4 @@
// Copyright (c) 2019 Uber Technologies, Inc.
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion codegen/reflect_interface.go
@@ -1,4 +1,4 @@
// Copyright (c) 2019 Uber Technologies, Inc.
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion codegen/runner/runner.go
@@ -1,4 +1,4 @@
// Copyright (c) 2019 Uber Technologies, Inc.
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 3 additions & 3 deletions codegen/service.go
@@ -1,4 +1,4 @@
// Copyright (c) 2019 Uber Technologies, Inc.
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -249,9 +249,9 @@ func (ms *ModuleSpec) SetDownstream(
)
}

if e.IsDummyEndpoint {
if e.IsClientlessEndpoint {
funcSpec := method.CompiledThriftSpec
err := method.setDummyTypeConverters(funcSpec, reqTransforms, headersPropagate, respTransforms, dummyReqTransforms, h)
err := method.setClientlessTypeConverters(funcSpec, reqTransforms, headersPropagate, respTransforms, dummyReqTransforms, h)
if err != nil {
return errors.Errorf(
"unable to set dummy type convertors for dummy endpoint")
Expand Down
2 changes: 1 addition & 1 deletion codegen/service_test.go
@@ -1,4 +1,4 @@
// Copyright (c) 2019 Uber Technologies, Inc.
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion codegen/template.go
@@ -1,4 +1,4 @@
// Copyright (c) 2019 Uber Technologies, Inc.
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
12 changes: 5 additions & 7 deletions codegen/template_bundle/template_files.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion codegen/template_test.go
@@ -1,4 +1,4 @@
// Copyright (c) 2019 Uber Technologies, Inc.
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 3 additions & 3 deletions codegen/templates/clientless-workflow.tmpl
Expand Up @@ -8,7 +8,7 @@ package clientlessworkflow
{{- $reqHeaderRequiredKeys := .ReqRequiredHeadersKeys }}
{{- $resHeaderMap := .ResHeaders }}
{{- $resHeaderMapKeys := .ResHeadersKeys }}
{{- $dummyEndpoint := .IsDummyEndpoint }}
{{- $clientlessEndpoint := .IsClientlessEndpoint }}
{{- $clientID := .ClientID }}
{{- $clientName := title .ClientName }}
{{- $clientMethodName := title .ClientMethodName }}
Expand Down Expand Up @@ -146,8 +146,8 @@ func (w {{$workflowStruct}}) Handle(
{{- end -}}
}

{{if eq $dummyEndpoint true -}}
{{ range $key, $line := $method.ConvertDummyRequestGoStatements -}}
{{if eq $clientlessEndpoint true -}}
{{ range $key, $line := $method.ConvertClientlessRequestGoStatements -}}
{{$line}}
{{ end }}
{{end -}}
Expand Down

0 comments on commit e668e50

Please sign in to comment.