From 767f58fb6bf26aa526ae09a93d9f9afef38f075d Mon Sep 17 00:00:00 2001 From: seeflood Date: Tue, 13 Sep 2022 14:18:22 +0800 Subject: [PATCH 1/5] feat(api): support email api & phone call api (#780) --- codecov.yml | 1 + components/email/interface_generated.go | 28 + components/email/struct_generated.go | 82 ++ components/email/types_generated.go | 79 ++ components/phone/interface_generated.go | 26 + components/phone/struct_generated.go | 43 + components/phone/types_generated.go | 79 ++ docs/_sidebar.md | 2 + docs/api/v1/email.html | 735 ++++++++++++++++++ docs/api/v1/phone.html | 571 ++++++++++++++ docs/api/v1/runtime.html | 3 +- docs/en/api_reference/README.md | 6 + docs/en/start/email/start.md | 122 +++ docs/en/start/phone/start.md | 122 +++ docs/zh/_sidebar.md | 2 + docs/zh/api_reference/README.md | 6 + docs/zh/start/email/start.md | 122 +++ docs/zh/start/phone/start.md | 122 +++ pkg/grpc/context_generated.go | 38 +- pkg/grpc/email/server.go | 135 ++++ pkg/grpc/phone/server.go | 98 +++ pkg/runtime/component_generated.go | 84 +- pkg/runtime/config_generated.go | 14 + pkg/runtime/context_generated.go | 9 +- pkg/runtime/options_generated.go | 31 +- sdk/go-sdk/client/client_generated.go | 56 +- spec/proto/extension/v1/email/email.pb.go | 700 +++++++++++++++++ spec/proto/extension/v1/email/email.proto | 1 - .../proto/extension/v1/email/email_grpc.pb.go | 140 ++++ spec/proto/extension/v1/phone/phone.pb.go | 356 +++++++++ spec/proto/extension/v1/phone/phone.proto | 1 - .../proto/extension/v1/phone/phone_grpc.pb.go | 102 +++ spec/proto/extension/v1/s3/oss.pb.go | 5 +- 33 files changed, 3878 insertions(+), 43 deletions(-) create mode 100644 components/email/interface_generated.go create mode 100644 components/email/struct_generated.go create mode 100644 components/email/types_generated.go create mode 100644 components/phone/interface_generated.go create mode 100644 components/phone/struct_generated.go create mode 100644 components/phone/types_generated.go create mode 100644 docs/api/v1/email.html create mode 100644 docs/api/v1/phone.html create mode 100644 docs/en/start/email/start.md create mode 100644 docs/en/start/phone/start.md create mode 100644 docs/zh/start/email/start.md create mode 100644 docs/zh/start/phone/start.md create mode 100644 pkg/grpc/email/server.go create mode 100644 pkg/grpc/phone/server.go create mode 100644 spec/proto/extension/v1/email/email.pb.go create mode 100644 spec/proto/extension/v1/email/email_grpc.pb.go create mode 100644 spec/proto/extension/v1/phone/phone.pb.go create mode 100644 spec/proto/extension/v1/phone/phone_grpc.pb.go diff --git a/codecov.yml b/codecov.yml index 0547c6c5c6..8be7b85a27 100644 --- a/codecov.yml +++ b/codecov.yml @@ -29,3 +29,4 @@ ignore: - "components/rpc/invoker/mosn/channel/xchannel.go" - "diagnostics/**/*" - "components/pkg/mock/**/*" + - "**/*_generated.go" diff --git a/components/email/interface_generated.go b/components/email/interface_generated.go new file mode 100644 index 0000000000..4c3faaeaa7 --- /dev/null +++ b/components/email/interface_generated.go @@ -0,0 +1,28 @@ +// Code generated by github.com/seeflood/protoc-gen-p6 . + +// Copyright 2021 Layotto Authors +// Licensed 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 email + +import ( + context "context" +) + +type EmailService interface { + Init(context.Context, *Config) error + + SendEmail(context.Context, *SendEmailRequest) (*SendEmailResponse, error) + + SendEmailWithTemplate(context.Context, *SendEmailWithTemplateRequest) (*SendEmailWithTemplateResponse, error) +} diff --git a/components/email/struct_generated.go b/components/email/struct_generated.go new file mode 100644 index 0000000000..b61101c8f6 --- /dev/null +++ b/components/email/struct_generated.go @@ -0,0 +1,82 @@ +// Code generated by github.com/seeflood/protoc-gen-p6 . + +// Copyright 2021 Layotto Authors +// Licensed 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 email + +// SendEmailWithTemplateRequest is the message send to email. +type SendEmailWithTemplateRequest struct { + // The saas service name, like 'aliyun.email'/'aws.ses'/'...' + // If your system uses multiple IVR services at the same time, + // you can specify which service to use with this field. + ComponentName string `json:"component_name,omitempty"` + // Required. + Template *EmailTemplate `json:"template,omitempty"` + // Required. The Email subject. + Subject string `json:"subject,omitempty"` + // Required. + Address *EmailAddress `json:"address,omitempty"` +} + +// Address information +type EmailAddress struct { + // Required. The Email sender address. + From string `json:"from,omitempty"` + // Required. The Email destination addresses. + To []string `json:"to,omitempty"` + // Optional. To whom the mail is cc + Cc []string `json:"cc,omitempty"` +} + +// Email template +type EmailTemplate struct { + // Required + TemplateId string `json:"template_id,omitempty"` + // Required + TemplateParams map[string]string `json:"template_params,omitempty"` +} + +// Response of `SendEmailWithTemplate` method +type SendEmailWithTemplateResponse struct { + // The saas requestId. + RequestId string `json:"request_id,omitempty"` +} + +// SendEmailRequest is the message send to email. +type SendEmailRequest struct { + // The saas service name, like 'aliyun.email'/'aws.ses'/'...' + // If your system uses multiple IVR services at the same time, + // you can specify which service to use with this field. + ComponentName string `json:"component_name,omitempty"` + // Required. + SettingId string `json:"setting_id,omitempty"` + // Required. The Email subject. + Subject string `json:"subject,omitempty"` + // Required. + Content *Content `json:"content,omitempty"` + // Required. + Address *EmailAddress `json:"address,omitempty"` +} + +// Email content +type Content struct { + // Required. + Text string `json:"text,omitempty"` +} + +// The response of `SendEmail` method +type SendEmailResponse struct { + // The saas requestId. + RequestId string `json:"request_id,omitempty"` +} diff --git a/components/email/types_generated.go b/components/email/types_generated.go new file mode 100644 index 0000000000..5e4224d7bd --- /dev/null +++ b/components/email/types_generated.go @@ -0,0 +1,79 @@ +// Code generated by github.com/seeflood/protoc-gen-p6 . + +// Copyright 2021 Layotto Authors +// Licensed 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 email + +import ( + fmt "fmt" + + info "mosn.io/layotto/components/pkg/info" + ref "mosn.io/layotto/components/ref" +) + +const ( + serviceName = "email" +) + +// Config is the component's configuration +type Config struct { + ref.Config + Type string `json:"type"` + Metadata map[string]string `json:"metadata"` +} + +type Registry interface { + Register(fs ...*Factory) + Create(compType string) (EmailService, error) +} + +type Factory struct { + CompType string + FactoryMethod func() EmailService +} + +func NewFactory(compType string, f func() EmailService) *Factory { + return &Factory{ + CompType: compType, + FactoryMethod: f, + } +} + +type registry struct { + stores map[string]func() EmailService + info *info.RuntimeInfo +} + +func NewRegistry(info *info.RuntimeInfo) Registry { + info.AddService(serviceName) + return ®istry{ + stores: make(map[string]func() EmailService), + info: info, + } +} + +func (r *registry) Register(fs ...*Factory) { + for _, f := range fs { + r.stores[f.CompType] = f.FactoryMethod + r.info.RegisterComponent(serviceName, f.CompType) + } +} + +func (r *registry) Create(compType string) (EmailService, error) { + if f, ok := r.stores[compType]; ok { + r.info.LoadComponent(serviceName, compType) + return f(), nil + } + return nil, fmt.Errorf("service component %s is not registered", compType) +} diff --git a/components/phone/interface_generated.go b/components/phone/interface_generated.go new file mode 100644 index 0000000000..4f2c0f5cf3 --- /dev/null +++ b/components/phone/interface_generated.go @@ -0,0 +1,26 @@ +// Code generated by github.com/seeflood/protoc-gen-p6 . + +// Copyright 2021 Layotto Authors +// Licensed 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 phone + +import ( + context "context" +) + +type PhoneCallService interface { + Init(context.Context, *Config) error + + SendVoiceWithTemplate(context.Context, *SendVoiceWithTemplateRequest) (*SendVoiceWithTemplateResponse, error) +} diff --git a/components/phone/struct_generated.go b/components/phone/struct_generated.go new file mode 100644 index 0000000000..18e240ec76 --- /dev/null +++ b/components/phone/struct_generated.go @@ -0,0 +1,43 @@ +// Code generated by github.com/seeflood/protoc-gen-p6 . + +// Copyright 2021 Layotto Authors +// Licensed 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 phone + +// The request of SendVoiceWithTemplate method +type SendVoiceWithTemplateRequest struct { + // If your system uses multiple IVR services at the same time, + // you can specify which service to use with this field. + ComponentName string `json:"component_name,omitempty"` + // Required + Template *VoiceTemplate `json:"template,omitempty"` + // Required + ToMobile []string `json:"to_mobile,omitempty"` + // This field is required by some cloud providers. + FromMobile string `json:"from_mobile,omitempty"` +} + +// VoiceTemplate +type VoiceTemplate struct { + // Required + TemplateId string `json:"template_id,omitempty"` + // Required + TemplateParams map[string]string `json:"template_params,omitempty"` +} + +// The response of `SendVoiceWithTemplate` method +type SendVoiceWithTemplateResponse struct { + // Id of this request. + RequestId string `json:"request_id,omitempty"` +} diff --git a/components/phone/types_generated.go b/components/phone/types_generated.go new file mode 100644 index 0000000000..f868e53dab --- /dev/null +++ b/components/phone/types_generated.go @@ -0,0 +1,79 @@ +// Code generated by github.com/seeflood/protoc-gen-p6 . + +// Copyright 2021 Layotto Authors +// Licensed 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 phone + +import ( + fmt "fmt" + + info "mosn.io/layotto/components/pkg/info" + ref "mosn.io/layotto/components/ref" +) + +const ( + serviceName = "phone" +) + +// Config is the component's configuration +type Config struct { + ref.Config + Type string `json:"type"` + Metadata map[string]string `json:"metadata"` +} + +type Registry interface { + Register(fs ...*Factory) + Create(compType string) (PhoneCallService, error) +} + +type Factory struct { + CompType string + FactoryMethod func() PhoneCallService +} + +func NewFactory(compType string, f func() PhoneCallService) *Factory { + return &Factory{ + CompType: compType, + FactoryMethod: f, + } +} + +type registry struct { + stores map[string]func() PhoneCallService + info *info.RuntimeInfo +} + +func NewRegistry(info *info.RuntimeInfo) Registry { + info.AddService(serviceName) + return ®istry{ + stores: make(map[string]func() PhoneCallService), + info: info, + } +} + +func (r *registry) Register(fs ...*Factory) { + for _, f := range fs { + r.stores[f.CompType] = f.FactoryMethod + r.info.RegisterComponent(serviceName, f.CompType) + } +} + +func (r *registry) Create(compType string) (PhoneCallService, error) { + if f, ok := r.stores[compType]; ok { + r.info.LoadComponent(serviceName, compType) + return f(), nil + } + return nil, fmt.Errorf("service component %s is not registered", compType) +} diff --git a/docs/_sidebar.md b/docs/_sidebar.md index 53a61cbc57..e4846536d9 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -16,6 +16,8 @@ - [Use OSS API](en/start/oss/start.md) - [API plugin: register your own API](en/start/api_plugin/helloworld.md) + - [(Under construction) Use phone API](en/start/phone/start) + - [(Under construction) Use email API](en/start/email/start) - [Use lifecycle API](en/start/lifecycle/start) - As the data plane of istio - [Integrate with istio 1.10.6](en/start/istio/) diff --git a/docs/api/v1/email.html b/docs/api/v1/email.html new file mode 100644 index 0000000000..15a47be189 --- /dev/null +++ b/docs/api/v1/email.html @@ -0,0 +1,735 @@ + + + + + Protocol Documentation + + + + + + + + + + +

Protocol Documentation

+ +

Table of Contents

+ +
+ +
+ + + +
+

email.proto

Top +
+

+ + +

[gRPC Service] EmailService

+

EmailService is used to send emails.

+ + + + + + + + + + + + + + + + + + + + + +
Method NameRequest TypeResponse TypeDescription
SendEmailWithTemplateSendEmailWithTemplateRequestSendEmailWithTemplateResponse

Send an email with template

SendEmailSendEmailRequestSendEmailResponse

Send an email with raw content instead of using templates.

+ + + + +

Content

+

Email content

+ + + + + + + + + + + + + + + + +
FieldTypeLabelDescription
textstring

Required.

+ + + + + +

EmailAddress

+

Address information

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldTypeLabelDescription
fromstring

Required. The Email sender address.

tostringrepeated

Required. The Email destination addresses.

ccstringrepeated

Optional. To whom the mail is cc

+ + + + + +

EmailTemplate

+

Email template

+ + + + + + + + + + + + + + + + + + + + + + + +
FieldTypeLabelDescription
template_idstring

Required

template_paramsEmailTemplate.TemplateParamsEntryrepeated

Required

+ + + + + +

EmailTemplate.TemplateParamsEntry

+

+ + + + + + + + + + + + + + + + + + + + + + + +
FieldTypeLabelDescription
keystring

valuestring

+ + + + + +

SendEmailRequest

+

SendEmailRequest is the message send to email.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldTypeLabelDescription
component_namestring

The saas service name, like 'aliyun.email'/'aws.ses'/'...' + If your system uses multiple IVR services at the same time, + you can specify which service to use with this field.

setting_idstring

Required.

subjectstring

Required. The Email subject.

contentContent

Required.

addressEmailAddress

Required.

+ + + + + +

SendEmailResponse

+

The response of `SendEmail` method

+ + + + + + + + + + + + + + + + +
FieldTypeLabelDescription
request_idstring

The saas requestId.

+ + + + + +

SendEmailWithTemplateRequest

+

SendEmailWithTemplateRequest is the message send to email.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldTypeLabelDescription
component_namestring

The saas service name, like 'aliyun.email'/'aws.ses'/'...' + If your system uses multiple IVR services at the same time, + you can specify which service to use with this field.

templateEmailTemplate

Required.

subjectstring

Required. The Email subject.

addressEmailAddress

Required.

+ + + + + +

SendEmailWithTemplateResponse

+

Response of `SendEmailWithTemplate` method

+ + + + + + + + + + + + + + + + +
FieldTypeLabelDescription
request_idstring

The saas requestId.

+ + + + + + + + + + + + +

Scalar Value Types

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
.proto TypeNotesC++JavaPythonGoC#PHPRuby
doubledoubledoublefloatfloat64doublefloatFloat
floatfloatfloatfloatfloat32floatfloatFloat
int32Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead.int32intintint32intintegerBignum or Fixnum (as required)
int64Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead.int64longint/longint64longinteger/stringBignum
uint32Uses variable-length encoding.uint32intint/longuint32uintintegerBignum or Fixnum (as required)
uint64Uses variable-length encoding.uint64longint/longuint64ulonginteger/stringBignum or Fixnum (as required)
sint32Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s.int32intintint32intintegerBignum or Fixnum (as required)
sint64Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s.int64longint/longint64longinteger/stringBignum
fixed32Always four bytes. More efficient than uint32 if values are often greater than 2^28.uint32intintuint32uintintegerBignum or Fixnum (as required)
fixed64Always eight bytes. More efficient than uint64 if values are often greater than 2^56.uint64longint/longuint64ulonginteger/stringBignum
sfixed32Always four bytes.int32intintint32intintegerBignum or Fixnum (as required)
sfixed64Always eight bytes.int64longint/longint64longinteger/stringBignum
boolboolbooleanbooleanboolboolbooleanTrueClass/FalseClass
stringA string must always contain UTF-8 encoded or 7-bit ASCII text.stringStringstr/unicodestringstringstringString (UTF-8)
bytesMay contain any arbitrary sequence of bytes.stringByteStringstr[]byteByteStringstringString (ASCII-8BIT)
+ + diff --git a/docs/api/v1/phone.html b/docs/api/v1/phone.html new file mode 100644 index 0000000000..60d0ae05d4 --- /dev/null +++ b/docs/api/v1/phone.html @@ -0,0 +1,571 @@ + + + + + Protocol Documentation + + + + + + + + + + +

Protocol Documentation

+ +

Table of Contents

+ +
+ +
+ + + +
+

phone.proto

Top +
+

+ + +

[gRPC Service] PhoneCallService

+

PhoneCallService is one of Notify APIs. It's used to send voice messages

+ + + + + + + + + + + + + + +
Method NameRequest TypeResponse TypeDescription
SendVoiceWithTemplateSendVoiceWithTemplateRequestSendVoiceWithTemplateResponse

Send voice using the specific template

+ + + + +

SendVoiceWithTemplateRequest

+

The request of SendVoiceWithTemplate method

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldTypeLabelDescription
component_namestring

If your system uses multiple IVR services at the same time, +you can specify which service to use with this field.

templateVoiceTemplate

Required

to_mobilestringrepeated

Required

from_mobilestring

This field is required by some cloud providers.

+ + + + + +

SendVoiceWithTemplateResponse

+

The response of `SendVoiceWithTemplate` method

+ + + + + + + + + + + + + + + + +
FieldTypeLabelDescription
request_idstring

Id of this request.

+ + + + + +

VoiceTemplate

+

VoiceTemplate

+ + + + + + + + + + + + + + + + + + + + + + + +
FieldTypeLabelDescription
template_idstring

Required

template_paramsVoiceTemplate.TemplateParamsEntryrepeated

Required

+ + + + + +

VoiceTemplate.TemplateParamsEntry

+

+ + + + + + + + + + + + + + + + + + + + + + + +
FieldTypeLabelDescription
keystring

valuestring

+ + + + + + + + + + + + +

Scalar Value Types

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
.proto TypeNotesC++JavaPythonGoC#PHPRuby
doubledoubledoublefloatfloat64doublefloatFloat
floatfloatfloatfloatfloat32floatfloatFloat
int32Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead.int32intintint32intintegerBignum or Fixnum (as required)
int64Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead.int64longint/longint64longinteger/stringBignum
uint32Uses variable-length encoding.uint32intint/longuint32uintintegerBignum or Fixnum (as required)
uint64Uses variable-length encoding.uint64longint/longuint64ulonginteger/stringBignum or Fixnum (as required)
sint32Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s.int32intintint32intintegerBignum or Fixnum (as required)
sint64Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s.int64longint/longint64longinteger/stringBignum
fixed32Always four bytes. More efficient than uint32 if values are often greater than 2^28.uint32intintuint32uintintegerBignum or Fixnum (as required)
fixed64Always eight bytes. More efficient than uint64 if values are often greater than 2^56.uint64longint/longuint64ulonginteger/stringBignum
sfixed32Always four bytes.int32intintint32intintegerBignum or Fixnum (as required)
sfixed64Always eight bytes.int64longint/longint64longinteger/stringBignum
boolboolbooleanbooleanboolboolbooleanTrueClass/FalseClass
stringA string must always contain UTF-8 encoded or 7-bit ASCII text.stringStringstr/unicodestringstringstringString (UTF-8)
bytesMay contain any arbitrary sequence of bytes.stringByteStringstr[]byteByteStringstringString (ASCII-8BIT)
+ + diff --git a/docs/api/v1/runtime.html b/docs/api/v1/runtime.html index c2c75b24fc..b7ac890a07 100644 --- a/docs/api/v1/runtime.html +++ b/docs/api/v1/runtime.html @@ -936,7 +936,8 @@

[gRPC Service] Lifecycle

ApplyConfiguration DynamicConfiguration ApplyConfigurationResponse -

apply the dynamic configuration

+

Apply the dynamic configuration. +The DynamicConfiguration here should be full configuration, not incremental configuration

diff --git a/docs/en/api_reference/README.md b/docs/en/api_reference/README.md index 7d98ef9fcc..0731db1cef 100644 --- a/docs/en/api_reference/README.md +++ b/docs/en/api_reference/README.md @@ -11,4 +11,10 @@ These protos define Layotto's runtime API, including: In addition to this, Layotto also provides some extension APIs, including: + + +email: [spec/proto/extension/v1/email](https://mosn.io/layotto/api/v1/email.html) + +phone: [spec/proto/extension/v1/phone](https://mosn.io/layotto/api/v1/phone.html) + s3: [spec/proto/extension/v1/s3](https://mosn.io/layotto/api/v1/s3.html) diff --git a/docs/en/start/email/start.md b/docs/en/start/email/start.md new file mode 100644 index 0000000000..3048223646 --- /dev/null +++ b/docs/en/start/email/start.md @@ -0,0 +1,122 @@ + +# EmailService API demo + +This example shows how to invoke Layotto EmailService API. + +EmailService is used to send emails. + +## step 1. Deploy Layotto + +### **With Docker** +You can start Layotto with docker + +```bash +docker run -v "$(pwd)/configs/config_standalone.json:/runtime/configs/config.json" -d -p 34904:34904 --name layotto layotto/layotto start +``` + +### **Compile locally (not for Windows)** +You can compile and run Layotto locally. + +> [!TIP|label: Not for Windows users] +> Layotto fails to compile under Windows. Windows users are recommended to deploy using docker + +After downloading the project code to the local, switch the code directory and compile: + +```shell +cd ${project_path}/cmd/layotto +``` + +```shell @if.not.exist layotto +go build +``` + +Once finished, the layotto binary will be generated in the directory. + +Run it: + +```shell @background +./layotto start -c ../../configs/config_standalone.json +``` + + + +## step 2. Run the client program to invoke Layotto EmailService API + +### **Go** +Build and run the golang demo: + +```shell + cd ${project_path}/demo/email/common/ + go build -o client + ./client -s "demo" +``` + +If the following information is printed, the demo is successful: + +```bash +TODO +``` + +### **Java** + +Download java sdk and examples: + +```shell @if.not.exist java-sdk +git clone https://github.com/layotto/java-sdk +``` + +```shell +cd java-sdk +``` + +Build the demo: + +```shell @if.not.exist examples-email/target/examples-email-1.1.0-jar-with-dependencies.jar +# build example jar +mvn -f examples-email/pom.xml clean package +``` + +Run it: + +```shell +java -jar examples-email/target/examples-email-1.1.0-jar-with-dependencies.jar +``` + +If the following information is printed, the demo is successful: + +```bash +TODO +``` + + + +## step 3. Stop containers and release resources + +### **Destroy the Docker container** +If you started Layotto with docker, you can destroy the container as follows: + +```bash +docker rm -f layotto +``` + + + +## Next step +### What does this client program do? +The demo client program uses the SDK provided by Layotto to invoke the Layotto EmailService API. + +The golang sdk is located in the `sdk` directory, and the java sdk is in https://github.com/layotto/java-sdk + +In addition to using sdk, you can also interact with Layotto directly through grpc in any language you like. + +### Details later, let's continue to experience other APIs +Explore other Quickstarts through the navigation bar on the left. + +### Reference + +[API Reference](https://mosn.io/layotto/api/v1/email.html) + + + + + diff --git a/docs/en/start/phone/start.md b/docs/en/start/phone/start.md new file mode 100644 index 0000000000..686d7a9334 --- /dev/null +++ b/docs/en/start/phone/start.md @@ -0,0 +1,122 @@ + +# PhoneCallService API demo + +This example shows how to invoke Layotto PhoneCallService API. + +PhoneCallService is one of Notify APIs. It's used to send voice messages + +## step 1. Deploy Layotto + +### **With Docker** +You can start Layotto with docker + +```bash +docker run -v "$(pwd)/configs/config_standalone.json:/runtime/configs/config.json" -d -p 34904:34904 --name layotto layotto/layotto start +``` + +### **Compile locally (not for Windows)** +You can compile and run Layotto locally. + +> [!TIP|label: Not for Windows users] +> Layotto fails to compile under Windows. Windows users are recommended to deploy using docker + +After downloading the project code to the local, switch the code directory and compile: + +```shell +cd ${project_path}/cmd/layotto +``` + +```shell @if.not.exist layotto +go build +``` + +Once finished, the layotto binary will be generated in the directory. + +Run it: + +```shell @background +./layotto start -c ../../configs/config_standalone.json +``` + + + +## step 2. Run the client program to invoke Layotto PhoneCallService API + +### **Go** +Build and run the golang demo: + +```shell + cd ${project_path}/demo/phone/common/ + go build -o client + ./client -s "demo" +``` + +If the following information is printed, the demo is successful: + +```bash +TODO +``` + +### **Java** + +Download java sdk and examples: + +```shell @if.not.exist java-sdk +git clone https://github.com/layotto/java-sdk +``` + +```shell +cd java-sdk +``` + +Build the demo: + +```shell @if.not.exist examples-phone/target/examples-phone-1.1.0-jar-with-dependencies.jar +# build example jar +mvn -f examples-phone/pom.xml clean package +``` + +Run it: + +```shell +java -jar examples-phone/target/examples-phone-1.1.0-jar-with-dependencies.jar +``` + +If the following information is printed, the demo is successful: + +```bash +TODO +``` + + + +## step 3. Stop containers and release resources + +### **Destroy the Docker container** +If you started Layotto with docker, you can destroy the container as follows: + +```bash +docker rm -f layotto +``` + + + +## Next step +### What does this client program do? +The demo client program uses the SDK provided by Layotto to invoke the Layotto PhoneCallService API. + +The golang sdk is located in the `sdk` directory, and the java sdk is in https://github.com/layotto/java-sdk + +In addition to using sdk, you can also interact with Layotto directly through grpc in any language you like. + +### Details later, let's continue to experience other APIs +Explore other Quickstarts through the navigation bar on the left. + +### Reference + +[API Reference](https://mosn.io/layotto/api/v1/phone.html) + + + + + diff --git a/docs/zh/_sidebar.md b/docs/zh/_sidebar.md index 57f890a6dd..dd66665be1 100644 --- a/docs/zh/_sidebar.md +++ b/docs/zh/_sidebar.md @@ -17,6 +17,8 @@ - [基于Minio](zh/start/file/minio.md) - [使用 OSS API](zh/start/oss/oss.md) + - [(建设中)使用 phone API](zh/start/phone/start) + - [(建设中)使用 email API](zh/start/email/start) - [使用 lifecycle API](zh/start/lifecycle/start) - [API插件:注册您自己的API](zh/start/api_plugin/helloworld.md) - 作为 Istio 的数据面 diff --git a/docs/zh/api_reference/README.md b/docs/zh/api_reference/README.md index c5b88649d3..f0c3815cf3 100644 --- a/docs/zh/api_reference/README.md +++ b/docs/zh/api_reference/README.md @@ -11,4 +11,10 @@ Layotto 有多个 gRPC proto 文件, 对应的接口文档在: 除此之外,Layotto 还提供了一些扩展 API,包括: + + +email: [spec/proto/extension/v1/email](https://mosn.io/layotto/api/v1/email.html) + +phone: [spec/proto/extension/v1/phone](https://mosn.io/layotto/api/v1/phone.html) + s3: [spec/proto/extension/v1/s3](https://mosn.io/layotto/api/v1/s3.html) diff --git a/docs/zh/start/email/start.md b/docs/zh/start/email/start.md new file mode 100644 index 0000000000..f30ae55f5a --- /dev/null +++ b/docs/zh/start/email/start.md @@ -0,0 +1,122 @@ + +# EmailService API demo + +本示例演示如何调用 Layotto EmailService API. + +EmailService is used to send emails. + +## step 1. 运行 Layotto + +### **With Docker** +您可以用 Docker 启动 Layotto + +```bash +docker run -v "$(pwd)/configs/config_standalone.json:/runtime/configs/config.json" -d -p 34904:34904 --name layotto layotto/layotto start +``` + +### **本地编译(不适合 Windows)** +您可以本地编译、运行 Layotto。 +> [!TIP|label: 不适合 Windows 用户] +> Layotto 在 Windows 下会编译失败。建议 Windows 用户使用 docker 部署 + +将项目代码下载到本地后,切换代码目录: + +```shell +cd ${project_path}/cmd/layotto +``` + +构建: + +```shell @if.not.exist layotto +go build +``` + +完成后目录下会生成 Layotto文件,运行它: + +```shell @background +./layotto start -c ../../configs/config_standalone.json +``` + + + +## step 2. 运行客户端程序,调用 Layotto EmailService API + +### **Go** + +构建、运行 go 语言 demo: + +```shell + cd ${project_path}/demo/email/common/ + go build -o client + ./client -s "demo" +``` + +打印出如下信息则代表调用成功: + +```bash +TODO +``` + +### **Java** + +下载 java sdk 和示例代码: + +```shell @if.not.exist java-sdk +git clone https://github.com/layotto/java-sdk +``` + +```shell +cd java-sdk +``` + +构建 examples: + +```shell @if.not.exist examples-email/target/examples-email-1.1.0-jar-with-dependencies.jar +# build example jar +mvn -f examples-email/pom.xml clean package +``` + +运行: + +```shell +java -jar examples-email/target/examples-email-1.1.0-jar-with-dependencies.jar +``` + +打印出以下信息说明运行成功: + +```bash +TODO +``` + + + +## step 3. 销毁容器,释放资源 + +### **销毁 Docker container** +如果您是用 Docker 启动的 Layotto,可以按以下方式销毁容器: + +```bash +docker rm -f layotto +``` + + + +## 下一步 +### 这个客户端程序做了什么? +示例客户端程序中使用了 Layotto 提供的多语言 sdk,调用Layotto EmailService API。 + +go sdk位于`sdk`目录下,java sdk 在 https://github.com/layotto/java-sdk + +除了使用sdk调用Layotto提供的API,您也可以用任何您喜欢的语言、通过grpc直接和Layotto交互。 + +### 细节以后再说,继续体验其他API +通过左侧的导航栏,继续体验别的API吧! + +### Reference + +[API Reference](https://mosn.io/layotto/api/v1/email.html) + + + + + diff --git a/docs/zh/start/phone/start.md b/docs/zh/start/phone/start.md new file mode 100644 index 0000000000..72af36c21d --- /dev/null +++ b/docs/zh/start/phone/start.md @@ -0,0 +1,122 @@ + +# PhoneCallService API demo + +本示例演示如何调用 Layotto PhoneCallService API. + +PhoneCallService is one of Notify APIs. It's used to send voice messages + +## step 1. 运行 Layotto + +### **With Docker** +您可以用 Docker 启动 Layotto + +```bash +docker run -v "$(pwd)/configs/config_standalone.json:/runtime/configs/config.json" -d -p 34904:34904 --name layotto layotto/layotto start +``` + +### **本地编译(不适合 Windows)** +您可以本地编译、运行 Layotto。 +> [!TIP|label: 不适合 Windows 用户] +> Layotto 在 Windows 下会编译失败。建议 Windows 用户使用 docker 部署 + +将项目代码下载到本地后,切换代码目录: + +```shell +cd ${project_path}/cmd/layotto +``` + +构建: + +```shell @if.not.exist layotto +go build +``` + +完成后目录下会生成 Layotto文件,运行它: + +```shell @background +./layotto start -c ../../configs/config_standalone.json +``` + + + +## step 2. 运行客户端程序,调用 Layotto PhoneCallService API + +### **Go** + +构建、运行 go 语言 demo: + +```shell + cd ${project_path}/demo/phone/common/ + go build -o client + ./client -s "demo" +``` + +打印出如下信息则代表调用成功: + +```bash +TODO +``` + +### **Java** + +下载 java sdk 和示例代码: + +```shell @if.not.exist java-sdk +git clone https://github.com/layotto/java-sdk +``` + +```shell +cd java-sdk +``` + +构建 examples: + +```shell @if.not.exist examples-phone/target/examples-phone-1.1.0-jar-with-dependencies.jar +# build example jar +mvn -f examples-phone/pom.xml clean package +``` + +运行: + +```shell +java -jar examples-phone/target/examples-phone-1.1.0-jar-with-dependencies.jar +``` + +打印出以下信息说明运行成功: + +```bash +TODO +``` + + + +## step 3. 销毁容器,释放资源 + +### **销毁 Docker container** +如果您是用 Docker 启动的 Layotto,可以按以下方式销毁容器: + +```bash +docker rm -f layotto +``` + + + +## 下一步 +### 这个客户端程序做了什么? +示例客户端程序中使用了 Layotto 提供的多语言 sdk,调用Layotto PhoneCallService API。 + +go sdk位于`sdk`目录下,java sdk 在 https://github.com/layotto/java-sdk + +除了使用sdk调用Layotto提供的API,您也可以用任何您喜欢的语言、通过grpc直接和Layotto交互。 + +### 细节以后再说,继续体验其他API +通过左侧的导航栏,继续体验别的API吧! + +### Reference + +[API Reference](https://mosn.io/layotto/api/v1/phone.html) + + + + + diff --git a/pkg/grpc/context_generated.go b/pkg/grpc/context_generated.go index 28d6d2c71b..2f6b642923 100644 --- a/pkg/grpc/context_generated.go +++ b/pkg/grpc/context_generated.go @@ -1,3 +1,5 @@ +// Code generated by github.com/seeflood/protoc-gen-p6 . + // Copyright 2021 Layotto Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,26 +16,27 @@ package grpc import ( - "github.com/dapr/components-contrib/bindings" - "github.com/dapr/components-contrib/pubsub" - "github.com/dapr/components-contrib/secretstores" - "github.com/dapr/components-contrib/state" - - "mosn.io/layotto/components/pkg/common" - "mosn.io/layotto/pkg/runtime/lifecycle" + bindings "github.com/dapr/components-contrib/bindings" + pubsub "github.com/dapr/components-contrib/pubsub" + secretstores "github.com/dapr/components-contrib/secretstores" + state "github.com/dapr/components-contrib/state" - "mosn.io/layotto/components/configstores" - "mosn.io/layotto/components/custom" - "mosn.io/layotto/components/file" - "mosn.io/layotto/components/hello" - "mosn.io/layotto/components/lock" - "mosn.io/layotto/components/oss" - "mosn.io/layotto/components/rpc" - "mosn.io/layotto/components/sequencer" + configstores "mosn.io/layotto/components/configstores" + custom "mosn.io/layotto/components/custom" + email "mosn.io/layotto/components/email" + file "mosn.io/layotto/components/file" + hello "mosn.io/layotto/components/hello" + lock "mosn.io/layotto/components/lock" + oss "mosn.io/layotto/components/oss" + phone "mosn.io/layotto/components/phone" + common "mosn.io/layotto/components/pkg/common" + rpc "mosn.io/layotto/components/rpc" + sequencer "mosn.io/layotto/components/sequencer" + lifecycle "mosn.io/layotto/pkg/runtime/lifecycle" ) // ApplicationContext contains all you need to construct your GrpcAPI, such as all the components. -// For example, your `SuperState` GrpcAPI can hold the `StateStores` components and use them to implement your own `Super State API` logic. +// For example, your "SuperState" GrpcAPI can hold the "StateStores" components and use them to implement your own "Super State API" logic. type ApplicationContext struct { AppId string Hellos map[string]hello.HelloService @@ -49,4 +52,7 @@ type ApplicationContext struct { SecretStores map[string]secretstores.SecretStore DynamicComponents map[lifecycle.ComponentKey]common.DynamicComponent CustomComponent map[string]map[string]custom.Component + EmailService map[string]email.EmailService + + PhoneCallService map[string]phone.PhoneCallService } diff --git a/pkg/grpc/email/server.go b/pkg/grpc/email/server.go new file mode 100644 index 0000000000..48beec5b89 --- /dev/null +++ b/pkg/grpc/email/server.go @@ -0,0 +1,135 @@ +// Code generated by github.com/seeflood/protoc-gen-p6. DO NOT EDIT. + +// Copyright 2021 Layotto Authors +// Licensed 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 email + +import ( + "context" + "encoding/json" + "fmt" + + "mosn.io/pkg/log" + + email "mosn.io/layotto/components/email" + email1 "mosn.io/layotto/spec/proto/extension/v1/email" + + rawGRPC "google.golang.org/grpc" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + grpc_api "mosn.io/layotto/pkg/grpc" +) + +func NewAPI(ac *grpc_api.ApplicationContext) grpc_api.GrpcAPI { + return &server{ + appId: ac.AppId, + components: ac.EmailService, + } +} + +type server struct { + appId string + components map[string]email.EmailService +} + +func (s *server) SendEmail(ctx context.Context, in *email1.SendEmailRequest) (*email1.SendEmailResponse, error) { + // find the component + comp := s.components[in.ComponentName] + if comp == nil { + return nil, invalidArgumentError("SendEmail", grpc_api.ErrComponentNotFound, "email1", in.ComponentName) + } + + // convert request + var req email.SendEmailRequest + bytes, err := json.Marshal(in) + if err != nil { + return nil, status.Errorf(codes.Internal, "Error when json.Marshal the request: %s", err.Error()) + } + err = json.Unmarshal(bytes, &req) + if err != nil { + return nil, status.Errorf(codes.Internal, "Error when json.Unmarshal the request: %s", err.Error()) + } + + // delegate to the component + resp, err := comp.SendEmail(ctx, &req) + if err != nil { + return nil, status.Errorf(codes.Internal, err.Error()) + } + + // convert response + var out email1.SendEmailResponse + bytes, err = json.Marshal(resp) + if err != nil { + return nil, status.Errorf(codes.Internal, "Error when json.Marshal the response: %s", err.Error()) + } + err = json.Unmarshal(bytes, &out) + if err != nil { + return nil, status.Errorf(codes.Internal, "Error when json.Unmarshal the response: %s", err.Error()) + } + return &out, nil +} + +func (s *server) SendEmailWithTemplate(ctx context.Context, in *email1.SendEmailWithTemplateRequest) (*email1.SendEmailWithTemplateResponse, error) { + // find the component + comp := s.components[in.ComponentName] + if comp == nil { + return nil, invalidArgumentError("SendEmailWithTemplate", grpc_api.ErrComponentNotFound, "email1", in.ComponentName) + } + + // convert request + var req email.SendEmailWithTemplateRequest + bytes, err := json.Marshal(in) + if err != nil { + return nil, status.Errorf(codes.Internal, "Error when json.Marshal the request: %s", err.Error()) + } + err = json.Unmarshal(bytes, &req) + if err != nil { + return nil, status.Errorf(codes.Internal, "Error when json.Unmarshal the request: %s", err.Error()) + } + + // delegate to the component + resp, err := comp.SendEmailWithTemplate(ctx, &req) + if err != nil { + return nil, status.Errorf(codes.Internal, err.Error()) + } + + // convert response + var out email1.SendEmailWithTemplateResponse + bytes, err = json.Marshal(resp) + if err != nil { + return nil, status.Errorf(codes.Internal, "Error when json.Marshal the response: %s", err.Error()) + } + err = json.Unmarshal(bytes, &out) + if err != nil { + return nil, status.Errorf(codes.Internal, "Error when json.Unmarshal the response: %s", err.Error()) + } + return &out, nil +} + +func invalidArgumentError(method string, format string, a ...interface{}) error { + err := status.Errorf(codes.InvalidArgument, format, a...) + log.DefaultLogger.Errorf(fmt.Sprintf("%s fail: %+v", method, err)) + return err +} + +func (s *server) Init(conn *rawGRPC.ClientConn) error { + return nil +} + +func (s *server) Register(rawGrpcServer *rawGRPC.Server) error { + email1.RegisterEmailServiceServer(rawGrpcServer, s) + return nil +} diff --git a/pkg/grpc/phone/server.go b/pkg/grpc/phone/server.go new file mode 100644 index 0000000000..e37633ec62 --- /dev/null +++ b/pkg/grpc/phone/server.go @@ -0,0 +1,98 @@ +// Code generated by github.com/seeflood/protoc-gen-p6. DO NOT EDIT. + +// Copyright 2021 Layotto Authors +// Licensed 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 phone + +import ( + "context" + "encoding/json" + "fmt" + + "mosn.io/pkg/log" + + phone "mosn.io/layotto/components/phone" + phone1 "mosn.io/layotto/spec/proto/extension/v1/phone" + + rawGRPC "google.golang.org/grpc" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + grpc_api "mosn.io/layotto/pkg/grpc" +) + +func NewAPI(ac *grpc_api.ApplicationContext) grpc_api.GrpcAPI { + return &server{ + appId: ac.AppId, + components: ac.PhoneCallService, + } +} + +type server struct { + appId string + components map[string]phone.PhoneCallService +} + +func (s *server) SendVoiceWithTemplate(ctx context.Context, in *phone1.SendVoiceWithTemplateRequest) (*phone1.SendVoiceWithTemplateResponse, error) { + // find the component + comp := s.components[in.ComponentName] + if comp == nil { + return nil, invalidArgumentError("SendVoiceWithTemplate", grpc_api.ErrComponentNotFound, "phone1", in.ComponentName) + } + + // convert request + var req phone.SendVoiceWithTemplateRequest + bytes, err := json.Marshal(in) + if err != nil { + return nil, status.Errorf(codes.Internal, "Error when json.Marshal the request: %s", err.Error()) + } + err = json.Unmarshal(bytes, &req) + if err != nil { + return nil, status.Errorf(codes.Internal, "Error when json.Unmarshal the request: %s", err.Error()) + } + + // delegate to the component + resp, err := comp.SendVoiceWithTemplate(ctx, &req) + if err != nil { + return nil, status.Errorf(codes.Internal, err.Error()) + } + + // convert response + var out phone1.SendVoiceWithTemplateResponse + bytes, err = json.Marshal(resp) + if err != nil { + return nil, status.Errorf(codes.Internal, "Error when json.Marshal the response: %s", err.Error()) + } + err = json.Unmarshal(bytes, &out) + if err != nil { + return nil, status.Errorf(codes.Internal, "Error when json.Unmarshal the response: %s", err.Error()) + } + return &out, nil +} + +func invalidArgumentError(method string, format string, a ...interface{}) error { + err := status.Errorf(codes.InvalidArgument, format, a...) + log.DefaultLogger.Errorf(fmt.Sprintf("%s fail: %+v", method, err)) + return err +} + +func (s *server) Init(conn *rawGRPC.ClientConn) error { + return nil +} + +func (s *server) Register(rawGrpcServer *rawGRPC.Server) error { + phone1.RegisterPhoneCallServiceServer(rawGrpcServer, s) + return nil +} diff --git a/pkg/runtime/component_generated.go b/pkg/runtime/component_generated.go index 14c8fb770f..eda24a5da9 100644 --- a/pkg/runtime/component_generated.go +++ b/pkg/runtime/component_generated.go @@ -1,3 +1,5 @@ +// Code generated by github.com/seeflood/protoc-gen-p6 . + // Copyright 2021 Layotto Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -13,13 +15,93 @@ package runtime +import ( + "context" + + "mosn.io/pkg/log" + + email "mosn.io/layotto/components/email" + phone "mosn.io/layotto/components/phone" +) + type extensionComponents struct { + emailService map[string]email.EmailService + + phoneCallService map[string]phone.PhoneCallService } func newExtensionComponents() *extensionComponents { - return &extensionComponents{} + return &extensionComponents{ + emailService: make(map[string]email.EmailService), + + phoneCallService: make(map[string]phone.PhoneCallService), + } +} + +func (m *MosnRuntime) initEmailService(factorys ...*email.Factory) error { + log.DefaultLogger.Infof("[runtime] init EmailService") + + // 1. register all implementation + reg := email.NewRegistry(m.info) + reg.Register(factorys...) + // 2. loop initializing + for name, config := range m.runtimeConfig.EmailService { + // 2.1. create the component + c, err := reg.Create(config.Type) + if err != nil { + m.errInt(err, "create the component %s failed", name) + return err + } + //inject secret to component + if config.Metadata, err = m.Injector.InjectSecretRef(config.SecretRef, config.Metadata); err != nil { + return err + } + // 2.2. init + if err := c.Init(context.TODO(), &config); err != nil { + m.errInt(err, "init the component %s failed", name) + return err + } + m.emailService[name] = c + } + return nil +} + +func (m *MosnRuntime) initPhoneCallService(factorys ...*phone.Factory) error { + log.DefaultLogger.Infof("[runtime] init PhoneCallService") + + // 1. register all implementation + reg := phone.NewRegistry(m.info) + reg.Register(factorys...) + // 2. loop initializing + for name, config := range m.runtimeConfig.PhoneCallService { + // 2.1. create the component + c, err := reg.Create(config.Type) + if err != nil { + m.errInt(err, "create the component %s failed", name) + return err + } + //inject secret to component + if config.Metadata, err = m.Injector.InjectSecretRef(config.SecretRef, config.Metadata); err != nil { + return err + } + // 2.2. init + if err := c.Init(context.TODO(), &config); err != nil { + m.errInt(err, "init the component %s failed", name) + return err + } + m.phoneCallService[name] = c + } + return nil } func (m *MosnRuntime) initExtensionComponent(s services) error { + if err := m.initEmailService(s.email...); err != nil { + return err + } + + if err := m.initPhoneCallService(s.phone...); err != nil { + return err + } + return nil } diff --git a/pkg/runtime/config_generated.go b/pkg/runtime/config_generated.go index 00b1894918..8cff33941f 100644 --- a/pkg/runtime/config_generated.go +++ b/pkg/runtime/config_generated.go @@ -1,3 +1,5 @@ +// Code generated by github.com/seeflood/protoc-gen-p6 . + // Copyright 2021 Layotto Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -13,5 +15,17 @@ package runtime +import ( + email "mosn.io/layotto/components/email" + phone "mosn.io/layotto/components/phone" +) + type ExtensionComponentConfig struct { + // "mosn.io/layotto/spec/proto/extension/v1/email" + // email. + EmailService map[string]email.Config `json:"email"` + + // "mosn.io/layotto/spec/proto/extension/v1/phone" + // phone. + PhoneCallService map[string]phone.Config `json:"phone"` } diff --git a/pkg/runtime/context_generated.go b/pkg/runtime/context_generated.go index 08c61611cc..2d6b797608 100644 --- a/pkg/runtime/context_generated.go +++ b/pkg/runtime/context_generated.go @@ -1,3 +1,5 @@ +// Code generated by github.com/seeflood/protoc-gen-p6 . + // Copyright 2021 Layotto Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -13,7 +15,9 @@ package runtime -import "mosn.io/layotto/pkg/grpc" +import ( + grpc "mosn.io/layotto/pkg/grpc" +) func newApplicationContext(m *MosnRuntime) *grpc.ApplicationContext { return &grpc.ApplicationContext{ @@ -31,5 +35,8 @@ func newApplicationContext(m *MosnRuntime) *grpc.ApplicationContext { SecretStores: m.secretStores, DynamicComponents: m.dynamicComponents, CustomComponent: m.customComponent, + EmailService: m.emailService, + + PhoneCallService: m.phoneCallService, } } diff --git a/pkg/runtime/options_generated.go b/pkg/runtime/options_generated.go index f7835a2cff..df973bd898 100644 --- a/pkg/runtime/options_generated.go +++ b/pkg/runtime/options_generated.go @@ -1,4 +1,4 @@ -// Code generated by github.com/seeflood/protoc-gen-p6. +// Code generated by github.com/seeflood/protoc-gen-p6 . // Copyright 2021 Layotto Authors // Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,14 +16,39 @@ package runtime import ( - s3ext "mosn.io/layotto/pkg/grpc/extension/s3" + email "mosn.io/layotto/components/email" + phone "mosn.io/layotto/components/phone" + email1 "mosn.io/layotto/pkg/grpc/email" + s3 "mosn.io/layotto/pkg/grpc/extension/s3" + phone1 "mosn.io/layotto/pkg/grpc/phone" ) type extensionComponentFactorys struct { + // "mosn.io/layotto/spec/proto/extension/v1/email" + // email. + email []*email.Factory + + // "mosn.io/layotto/spec/proto/extension/v1/phone" + // phone. + phone []*phone.Factory +} + +func WithEmailServiceFactory(email ...*email.Factory) Option { + return func(o *runtimeOptions) { + o.services.email = append(o.services.email, email...) + } +} + +func WithPhoneCallServiceFactory(phone ...*phone.Factory) Option { + return func(o *runtimeOptions) { + o.services.phone = append(o.services.phone, phone...) + } } func WithExtensionGrpcAPI() Option { return WithGrpcAPI( - s3ext.NewS3Server, + s3.NewS3Server, + email1.NewAPI, + phone1.NewAPI, ) } diff --git a/sdk/go-sdk/client/client_generated.go b/sdk/go-sdk/client/client_generated.go index 6c061cdd48..0524c93e04 100644 --- a/sdk/go-sdk/client/client_generated.go +++ b/sdk/go-sdk/client/client_generated.go @@ -1,34 +1,45 @@ -/* - * Copyright 2021 Layotto Authors - * - * Licensed 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. - */ +// Code generated by github.com/seeflood/protoc-gen-p6 . + +// Copyright 2021 Layotto Authors +// Licensed 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 client import ( - "google.golang.org/grpc" + context "context" - v1 "mosn.io/layotto/spec/proto/runtime/v1" + grpc "google.golang.org/grpc" - "mosn.io/layotto/spec/proto/extension/v1/s3" + email "mosn.io/layotto/spec/proto/extension/v1/email" + phone "mosn.io/layotto/spec/proto/extension/v1/phone" + s3 "mosn.io/layotto/spec/proto/extension/v1/s3" + v1 "mosn.io/layotto/spec/proto/runtime/v1" ) +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context + // Client is the interface for runtime client implementation. type Client interface { runtimeAPI s3.ObjectStorageServiceClient + + // "mosn.io/layotto/spec/proto/extension/v1/email" + email.EmailServiceClient + + // "mosn.io/layotto/spec/proto/extension/v1/phone" + phone.PhoneCallServiceClient } // NewClientWithConnection instantiates runtime client using specific connection. @@ -37,6 +48,11 @@ func NewClientWithConnection(conn *grpc.ClientConn) Client { connection: conn, protoClient: v1.NewRuntimeClient(conn), ObjectStorageServiceClient: s3.NewObjectStorageServiceClient(conn), + // "mosn.io/layotto/spec/proto/extension/v1/email" + EmailServiceClient: email.NewEmailServiceClient(conn), + + // "mosn.io/layotto/spec/proto/extension/v1/phone" + PhoneCallServiceClient: phone.NewPhoneCallServiceClient(conn), } } @@ -45,4 +61,8 @@ type GRPCClient struct { connection *grpc.ClientConn protoClient v1.RuntimeClient s3.ObjectStorageServiceClient + // "mosn.io/layotto/spec/proto/extension/v1/email" + email.EmailServiceClient + // "mosn.io/layotto/spec/proto/extension/v1/phone" + phone.PhoneCallServiceClient } diff --git a/spec/proto/extension/v1/email/email.pb.go b/spec/proto/extension/v1/email/email.pb.go new file mode 100644 index 0000000000..d3d3a1d185 --- /dev/null +++ b/spec/proto/extension/v1/email/email.pb.go @@ -0,0 +1,700 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.26.0 +// protoc v3.14.0 +// source: spec/proto/extension/v1/email/email.proto + +package email + +import ( + reflect "reflect" + sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// SendEmailWithTemplateRequest is the message send to email. +type SendEmailWithTemplateRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The saas service name, like 'aliyun.email'/'aws.ses'/'...' + // If your system uses multiple IVR services at the same time, + // you can specify which service to use with this field. + ComponentName string `protobuf:"bytes,1,opt,name=component_name,json=componentName,proto3" json:"component_name,omitempty"` + // Required. + Template *EmailTemplate `protobuf:"bytes,2,opt,name=template,proto3" json:"template,omitempty"` + // Required. The Email subject. + Subject string `protobuf:"bytes,3,opt,name=subject,proto3" json:"subject,omitempty"` + // Required. + Address *EmailAddress `protobuf:"bytes,4,opt,name=address,proto3" json:"address,omitempty"` +} + +func (x *SendEmailWithTemplateRequest) Reset() { + *x = SendEmailWithTemplateRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_spec_proto_extension_v1_email_email_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SendEmailWithTemplateRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SendEmailWithTemplateRequest) ProtoMessage() {} + +func (x *SendEmailWithTemplateRequest) ProtoReflect() protoreflect.Message { + mi := &file_spec_proto_extension_v1_email_email_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SendEmailWithTemplateRequest.ProtoReflect.Descriptor instead. +func (*SendEmailWithTemplateRequest) Descriptor() ([]byte, []int) { + return file_spec_proto_extension_v1_email_email_proto_rawDescGZIP(), []int{0} +} + +func (x *SendEmailWithTemplateRequest) GetComponentName() string { + if x != nil { + return x.ComponentName + } + return "" +} + +func (x *SendEmailWithTemplateRequest) GetTemplate() *EmailTemplate { + if x != nil { + return x.Template + } + return nil +} + +func (x *SendEmailWithTemplateRequest) GetSubject() string { + if x != nil { + return x.Subject + } + return "" +} + +func (x *SendEmailWithTemplateRequest) GetAddress() *EmailAddress { + if x != nil { + return x.Address + } + return nil +} + +// Address information +type EmailAddress struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Required. The Email sender address. + From string `protobuf:"bytes,1,opt,name=from,proto3" json:"from,omitempty"` + // Required. The Email destination addresses. + To []string `protobuf:"bytes,2,rep,name=to,proto3" json:"to,omitempty"` + // Optional. To whom the mail is cc + Cc []string `protobuf:"bytes,3,rep,name=cc,proto3" json:"cc,omitempty"` +} + +func (x *EmailAddress) Reset() { + *x = EmailAddress{} + if protoimpl.UnsafeEnabled { + mi := &file_spec_proto_extension_v1_email_email_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *EmailAddress) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EmailAddress) ProtoMessage() {} + +func (x *EmailAddress) ProtoReflect() protoreflect.Message { + mi := &file_spec_proto_extension_v1_email_email_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EmailAddress.ProtoReflect.Descriptor instead. +func (*EmailAddress) Descriptor() ([]byte, []int) { + return file_spec_proto_extension_v1_email_email_proto_rawDescGZIP(), []int{1} +} + +func (x *EmailAddress) GetFrom() string { + if x != nil { + return x.From + } + return "" +} + +func (x *EmailAddress) GetTo() []string { + if x != nil { + return x.To + } + return nil +} + +func (x *EmailAddress) GetCc() []string { + if x != nil { + return x.Cc + } + return nil +} + +// Email template +type EmailTemplate struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Required + TemplateId string `protobuf:"bytes,1,opt,name=template_id,json=templateId,proto3" json:"template_id,omitempty"` + // Required + TemplateParams map[string]string `protobuf:"bytes,2,rep,name=template_params,json=templateParams,proto3" json:"template_params,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *EmailTemplate) Reset() { + *x = EmailTemplate{} + if protoimpl.UnsafeEnabled { + mi := &file_spec_proto_extension_v1_email_email_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *EmailTemplate) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EmailTemplate) ProtoMessage() {} + +func (x *EmailTemplate) ProtoReflect() protoreflect.Message { + mi := &file_spec_proto_extension_v1_email_email_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EmailTemplate.ProtoReflect.Descriptor instead. +func (*EmailTemplate) Descriptor() ([]byte, []int) { + return file_spec_proto_extension_v1_email_email_proto_rawDescGZIP(), []int{2} +} + +func (x *EmailTemplate) GetTemplateId() string { + if x != nil { + return x.TemplateId + } + return "" +} + +func (x *EmailTemplate) GetTemplateParams() map[string]string { + if x != nil { + return x.TemplateParams + } + return nil +} + +// Response of `SendEmailWithTemplate` method +type SendEmailWithTemplateResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The saas requestId. + RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` +} + +func (x *SendEmailWithTemplateResponse) Reset() { + *x = SendEmailWithTemplateResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_spec_proto_extension_v1_email_email_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SendEmailWithTemplateResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SendEmailWithTemplateResponse) ProtoMessage() {} + +func (x *SendEmailWithTemplateResponse) ProtoReflect() protoreflect.Message { + mi := &file_spec_proto_extension_v1_email_email_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SendEmailWithTemplateResponse.ProtoReflect.Descriptor instead. +func (*SendEmailWithTemplateResponse) Descriptor() ([]byte, []int) { + return file_spec_proto_extension_v1_email_email_proto_rawDescGZIP(), []int{3} +} + +func (x *SendEmailWithTemplateResponse) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +// SendEmailRequest is the message send to email. +type SendEmailRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The saas service name, like 'aliyun.email'/'aws.ses'/'...' + // If your system uses multiple IVR services at the same time, + // you can specify which service to use with this field. + ComponentName string `protobuf:"bytes,1,opt,name=component_name,json=componentName,proto3" json:"component_name,omitempty"` + // Required. + SettingId string `protobuf:"bytes,2,opt,name=setting_id,json=settingId,proto3" json:"setting_id,omitempty"` + // Required. The Email subject. + Subject string `protobuf:"bytes,3,opt,name=subject,proto3" json:"subject,omitempty"` + // Required. + Content *Content `protobuf:"bytes,4,opt,name=content,proto3" json:"content,omitempty"` + // Required. + Address *EmailAddress `protobuf:"bytes,5,opt,name=address,proto3" json:"address,omitempty"` +} + +func (x *SendEmailRequest) Reset() { + *x = SendEmailRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_spec_proto_extension_v1_email_email_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SendEmailRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SendEmailRequest) ProtoMessage() {} + +func (x *SendEmailRequest) ProtoReflect() protoreflect.Message { + mi := &file_spec_proto_extension_v1_email_email_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SendEmailRequest.ProtoReflect.Descriptor instead. +func (*SendEmailRequest) Descriptor() ([]byte, []int) { + return file_spec_proto_extension_v1_email_email_proto_rawDescGZIP(), []int{4} +} + +func (x *SendEmailRequest) GetComponentName() string { + if x != nil { + return x.ComponentName + } + return "" +} + +func (x *SendEmailRequest) GetSettingId() string { + if x != nil { + return x.SettingId + } + return "" +} + +func (x *SendEmailRequest) GetSubject() string { + if x != nil { + return x.Subject + } + return "" +} + +func (x *SendEmailRequest) GetContent() *Content { + if x != nil { + return x.Content + } + return nil +} + +func (x *SendEmailRequest) GetAddress() *EmailAddress { + if x != nil { + return x.Address + } + return nil +} + +// Email content +type Content struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Required. + Text string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"` +} + +func (x *Content) Reset() { + *x = Content{} + if protoimpl.UnsafeEnabled { + mi := &file_spec_proto_extension_v1_email_email_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Content) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Content) ProtoMessage() {} + +func (x *Content) ProtoReflect() protoreflect.Message { + mi := &file_spec_proto_extension_v1_email_email_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Content.ProtoReflect.Descriptor instead. +func (*Content) Descriptor() ([]byte, []int) { + return file_spec_proto_extension_v1_email_email_proto_rawDescGZIP(), []int{5} +} + +func (x *Content) GetText() string { + if x != nil { + return x.Text + } + return "" +} + +// The response of `SendEmail` method +type SendEmailResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The saas requestId. + RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` +} + +func (x *SendEmailResponse) Reset() { + *x = SendEmailResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_spec_proto_extension_v1_email_email_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SendEmailResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SendEmailResponse) ProtoMessage() {} + +func (x *SendEmailResponse) ProtoReflect() protoreflect.Message { + mi := &file_spec_proto_extension_v1_email_email_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SendEmailResponse.ProtoReflect.Descriptor instead. +func (*SendEmailResponse) Descriptor() ([]byte, []int) { + return file_spec_proto_extension_v1_email_email_proto_rawDescGZIP(), []int{6} +} + +func (x *SendEmailResponse) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +var File_spec_proto_extension_v1_email_email_proto protoreflect.FileDescriptor + +var file_spec_proto_extension_v1_email_email_proto_rawDesc = []byte{ + 0x0a, 0x29, 0x73, 0x70, 0x65, 0x63, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x74, + 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x2f, + 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1d, 0x73, 0x70, 0x65, + 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, + 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x22, 0xf0, 0x01, 0x0a, 0x1c, 0x53, + 0x65, 0x6e, 0x64, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x57, 0x69, 0x74, 0x68, 0x54, 0x65, 0x6d, 0x70, + 0x6c, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x63, + 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0d, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x4e, 0x61, + 0x6d, 0x65, 0x12, 0x48, 0x0a, 0x08, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x73, 0x70, 0x65, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x65, + 0x6d, 0x61, 0x69, 0x6c, 0x2e, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, + 0x74, 0x65, 0x52, 0x08, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x12, 0x18, 0x0a, 0x07, + 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, + 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x45, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x73, 0x70, 0x65, 0x63, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x76, + 0x31, 0x2e, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x2e, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x41, 0x64, 0x64, + 0x72, 0x65, 0x73, 0x73, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x42, 0x0a, + 0x0c, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x12, 0x0a, + 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x72, 0x6f, + 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x02, 0x74, + 0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x63, 0x63, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x02, 0x63, + 0x63, 0x22, 0xde, 0x01, 0x0a, 0x0d, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x54, 0x65, 0x6d, 0x70, 0x6c, + 0x61, 0x74, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x5f, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, + 0x74, 0x65, 0x49, 0x64, 0x12, 0x69, 0x0a, 0x0f, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, + 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x40, 0x2e, + 0x73, 0x70, 0x65, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x74, 0x65, 0x6e, + 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x2e, 0x45, 0x6d, + 0x61, 0x69, 0x6c, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x2e, 0x54, 0x65, 0x6d, 0x70, + 0x6c, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, + 0x0e, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, + 0x41, 0x0a, 0x13, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, + 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, + 0x38, 0x01, 0x22, 0x3e, 0x0a, 0x1d, 0x53, 0x65, 0x6e, 0x64, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x57, + 0x69, 0x74, 0x68, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x49, 0x64, 0x22, 0xfb, 0x01, 0x0a, 0x10, 0x53, 0x65, 0x6e, 0x64, 0x45, 0x6d, 0x61, 0x69, 0x6c, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x63, 0x6f, 0x6d, 0x70, 0x6f, + 0x6e, 0x65, 0x6e, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0d, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1d, + 0x0a, 0x0a, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x49, 0x64, 0x12, 0x18, 0x0a, + 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x40, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, + 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x73, 0x70, 0x65, 0x63, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x2e, + 0x76, 0x31, 0x2e, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, + 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x45, 0x0a, 0x07, 0x61, 0x64, 0x64, + 0x72, 0x65, 0x73, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x73, 0x70, 0x65, + 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, + 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x2e, 0x45, 0x6d, 0x61, 0x69, 0x6c, + 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, + 0x22, 0x1d, 0x0a, 0x07, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x74, + 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, + 0x32, 0x0a, 0x11, 0x53, 0x65, 0x6e, 0x64, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x49, 0x64, 0x32, 0x97, 0x02, 0x0a, 0x0c, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x12, 0x94, 0x01, 0x0a, 0x15, 0x53, 0x65, 0x6e, 0x64, 0x45, 0x6d, 0x61, + 0x69, 0x6c, 0x57, 0x69, 0x74, 0x68, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x12, 0x3b, + 0x2e, 0x73, 0x70, 0x65, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x74, 0x65, + 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x2e, 0x53, + 0x65, 0x6e, 0x64, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x57, 0x69, 0x74, 0x68, 0x54, 0x65, 0x6d, 0x70, + 0x6c, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3c, 0x2e, 0x73, 0x70, + 0x65, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, + 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x2e, 0x53, 0x65, 0x6e, 0x64, + 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x57, 0x69, 0x74, 0x68, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, + 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x70, 0x0a, 0x09, 0x53, + 0x65, 0x6e, 0x64, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x2f, 0x2e, 0x73, 0x70, 0x65, 0x63, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x2e, + 0x76, 0x31, 0x2e, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x45, 0x6d, 0x61, + 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x73, 0x70, 0x65, 0x63, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, + 0x2e, 0x76, 0x31, 0x2e, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x45, 0x6d, + 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x35, 0x5a, + 0x33, 0x6d, 0x6f, 0x73, 0x6e, 0x2e, 0x69, 0x6f, 0x2f, 0x6c, 0x61, 0x79, 0x6f, 0x74, 0x74, 0x6f, + 0x2f, 0x73, 0x70, 0x65, 0x63, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x74, 0x65, + 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x3b, 0x65, + 0x6d, 0x61, 0x69, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_spec_proto_extension_v1_email_email_proto_rawDescOnce sync.Once + file_spec_proto_extension_v1_email_email_proto_rawDescData = file_spec_proto_extension_v1_email_email_proto_rawDesc +) + +func file_spec_proto_extension_v1_email_email_proto_rawDescGZIP() []byte { + file_spec_proto_extension_v1_email_email_proto_rawDescOnce.Do(func() { + file_spec_proto_extension_v1_email_email_proto_rawDescData = protoimpl.X.CompressGZIP(file_spec_proto_extension_v1_email_email_proto_rawDescData) + }) + return file_spec_proto_extension_v1_email_email_proto_rawDescData +} + +var file_spec_proto_extension_v1_email_email_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_spec_proto_extension_v1_email_email_proto_goTypes = []interface{}{ + (*SendEmailWithTemplateRequest)(nil), // 0: spec.proto.extension.v1.email.SendEmailWithTemplateRequest + (*EmailAddress)(nil), // 1: spec.proto.extension.v1.email.EmailAddress + (*EmailTemplate)(nil), // 2: spec.proto.extension.v1.email.EmailTemplate + (*SendEmailWithTemplateResponse)(nil), // 3: spec.proto.extension.v1.email.SendEmailWithTemplateResponse + (*SendEmailRequest)(nil), // 4: spec.proto.extension.v1.email.SendEmailRequest + (*Content)(nil), // 5: spec.proto.extension.v1.email.Content + (*SendEmailResponse)(nil), // 6: spec.proto.extension.v1.email.SendEmailResponse + nil, // 7: spec.proto.extension.v1.email.EmailTemplate.TemplateParamsEntry +} +var file_spec_proto_extension_v1_email_email_proto_depIdxs = []int32{ + 2, // 0: spec.proto.extension.v1.email.SendEmailWithTemplateRequest.template:type_name -> spec.proto.extension.v1.email.EmailTemplate + 1, // 1: spec.proto.extension.v1.email.SendEmailWithTemplateRequest.address:type_name -> spec.proto.extension.v1.email.EmailAddress + 7, // 2: spec.proto.extension.v1.email.EmailTemplate.template_params:type_name -> spec.proto.extension.v1.email.EmailTemplate.TemplateParamsEntry + 5, // 3: spec.proto.extension.v1.email.SendEmailRequest.content:type_name -> spec.proto.extension.v1.email.Content + 1, // 4: spec.proto.extension.v1.email.SendEmailRequest.address:type_name -> spec.proto.extension.v1.email.EmailAddress + 0, // 5: spec.proto.extension.v1.email.EmailService.SendEmailWithTemplate:input_type -> spec.proto.extension.v1.email.SendEmailWithTemplateRequest + 4, // 6: spec.proto.extension.v1.email.EmailService.SendEmail:input_type -> spec.proto.extension.v1.email.SendEmailRequest + 3, // 7: spec.proto.extension.v1.email.EmailService.SendEmailWithTemplate:output_type -> spec.proto.extension.v1.email.SendEmailWithTemplateResponse + 6, // 8: spec.proto.extension.v1.email.EmailService.SendEmail:output_type -> spec.proto.extension.v1.email.SendEmailResponse + 7, // [7:9] is the sub-list for method output_type + 5, // [5:7] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name +} + +func init() { file_spec_proto_extension_v1_email_email_proto_init() } +func file_spec_proto_extension_v1_email_email_proto_init() { + if File_spec_proto_extension_v1_email_email_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_spec_proto_extension_v1_email_email_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SendEmailWithTemplateRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_spec_proto_extension_v1_email_email_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*EmailAddress); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_spec_proto_extension_v1_email_email_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*EmailTemplate); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_spec_proto_extension_v1_email_email_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SendEmailWithTemplateResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_spec_proto_extension_v1_email_email_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SendEmailRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_spec_proto_extension_v1_email_email_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Content); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_spec_proto_extension_v1_email_email_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SendEmailResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_spec_proto_extension_v1_email_email_proto_rawDesc, + NumEnums: 0, + NumMessages: 8, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_spec_proto_extension_v1_email_email_proto_goTypes, + DependencyIndexes: file_spec_proto_extension_v1_email_email_proto_depIdxs, + MessageInfos: file_spec_proto_extension_v1_email_email_proto_msgTypes, + }.Build() + File_spec_proto_extension_v1_email_email_proto = out.File + file_spec_proto_extension_v1_email_email_proto_rawDesc = nil + file_spec_proto_extension_v1_email_email_proto_goTypes = nil + file_spec_proto_extension_v1_email_email_proto_depIdxs = nil +} diff --git a/spec/proto/extension/v1/email/email.proto b/spec/proto/extension/v1/email/email.proto index e0921d6bf6..1bf4b9ef93 100644 --- a/spec/proto/extension/v1/email/email.proto +++ b/spec/proto/extension/v1/email/email.proto @@ -4,7 +4,6 @@ package spec.proto.extension.v1.email; option go_package = "mosn.io/layotto/spec/proto/extension/v1/email;email"; -/* @exclude quickstart generator */ // EmailService is used to send emails. service EmailService { diff --git a/spec/proto/extension/v1/email/email_grpc.pb.go b/spec/proto/extension/v1/email/email_grpc.pb.go new file mode 100644 index 0000000000..94b039b2a6 --- /dev/null +++ b/spec/proto/extension/v1/email/email_grpc.pb.go @@ -0,0 +1,140 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. + +package email + +import ( + context "context" + + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// EmailServiceClient is the client API for EmailService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type EmailServiceClient interface { + // Send an email with template + SendEmailWithTemplate(ctx context.Context, in *SendEmailWithTemplateRequest, opts ...grpc.CallOption) (*SendEmailWithTemplateResponse, error) + // Send an email with raw content instead of using templates. + SendEmail(ctx context.Context, in *SendEmailRequest, opts ...grpc.CallOption) (*SendEmailResponse, error) +} + +type emailServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewEmailServiceClient(cc grpc.ClientConnInterface) EmailServiceClient { + return &emailServiceClient{cc} +} + +func (c *emailServiceClient) SendEmailWithTemplate(ctx context.Context, in *SendEmailWithTemplateRequest, opts ...grpc.CallOption) (*SendEmailWithTemplateResponse, error) { + out := new(SendEmailWithTemplateResponse) + err := c.cc.Invoke(ctx, "/spec.proto.extension.v1.email.EmailService/SendEmailWithTemplate", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *emailServiceClient) SendEmail(ctx context.Context, in *SendEmailRequest, opts ...grpc.CallOption) (*SendEmailResponse, error) { + out := new(SendEmailResponse) + err := c.cc.Invoke(ctx, "/spec.proto.extension.v1.email.EmailService/SendEmail", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// EmailServiceServer is the server API for EmailService service. +// All implementations should embed UnimplementedEmailServiceServer +// for forward compatibility +type EmailServiceServer interface { + // Send an email with template + SendEmailWithTemplate(context.Context, *SendEmailWithTemplateRequest) (*SendEmailWithTemplateResponse, error) + // Send an email with raw content instead of using templates. + SendEmail(context.Context, *SendEmailRequest) (*SendEmailResponse, error) +} + +// UnimplementedEmailServiceServer should be embedded to have forward compatible implementations. +type UnimplementedEmailServiceServer struct { +} + +func (UnimplementedEmailServiceServer) SendEmailWithTemplate(context.Context, *SendEmailWithTemplateRequest) (*SendEmailWithTemplateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendEmailWithTemplate not implemented") +} +func (UnimplementedEmailServiceServer) SendEmail(context.Context, *SendEmailRequest) (*SendEmailResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendEmail not implemented") +} + +// UnsafeEmailServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to EmailServiceServer will +// result in compilation errors. +type UnsafeEmailServiceServer interface { + mustEmbedUnimplementedEmailServiceServer() +} + +func RegisterEmailServiceServer(s grpc.ServiceRegistrar, srv EmailServiceServer) { + s.RegisterService(&EmailService_ServiceDesc, srv) +} + +func _EmailService_SendEmailWithTemplate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SendEmailWithTemplateRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(EmailServiceServer).SendEmailWithTemplate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/spec.proto.extension.v1.email.EmailService/SendEmailWithTemplate", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(EmailServiceServer).SendEmailWithTemplate(ctx, req.(*SendEmailWithTemplateRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _EmailService_SendEmail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SendEmailRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(EmailServiceServer).SendEmail(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/spec.proto.extension.v1.email.EmailService/SendEmail", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(EmailServiceServer).SendEmail(ctx, req.(*SendEmailRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// EmailService_ServiceDesc is the grpc.ServiceDesc for EmailService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var EmailService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "spec.proto.extension.v1.email.EmailService", + HandlerType: (*EmailServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "SendEmailWithTemplate", + Handler: _EmailService_SendEmailWithTemplate_Handler, + }, + { + MethodName: "SendEmail", + Handler: _EmailService_SendEmail_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "spec/proto/extension/v1/email/email.proto", +} diff --git a/spec/proto/extension/v1/phone/phone.pb.go b/spec/proto/extension/v1/phone/phone.pb.go new file mode 100644 index 0000000000..28fd57368a --- /dev/null +++ b/spec/proto/extension/v1/phone/phone.pb.go @@ -0,0 +1,356 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.26.0 +// protoc v3.14.0 +// source: spec/proto/extension/v1/phone/phone.proto + +package phone + +import ( + reflect "reflect" + sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// The request of SendVoiceWithTemplate method +type SendVoiceWithTemplateRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // If your system uses multiple IVR services at the same time, + // you can specify which service to use with this field. + ComponentName string `protobuf:"bytes,1,opt,name=component_name,json=componentName,proto3" json:"component_name,omitempty"` + // Required + Template *VoiceTemplate `protobuf:"bytes,2,opt,name=template,proto3" json:"template,omitempty"` + // Required + ToMobile []string `protobuf:"bytes,3,rep,name=to_mobile,json=toMobile,proto3" json:"to_mobile,omitempty"` + // This field is required by some cloud providers. + FromMobile string `protobuf:"bytes,4,opt,name=from_mobile,json=fromMobile,proto3" json:"from_mobile,omitempty"` +} + +func (x *SendVoiceWithTemplateRequest) Reset() { + *x = SendVoiceWithTemplateRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_spec_proto_extension_v1_phone_phone_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SendVoiceWithTemplateRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SendVoiceWithTemplateRequest) ProtoMessage() {} + +func (x *SendVoiceWithTemplateRequest) ProtoReflect() protoreflect.Message { + mi := &file_spec_proto_extension_v1_phone_phone_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SendVoiceWithTemplateRequest.ProtoReflect.Descriptor instead. +func (*SendVoiceWithTemplateRequest) Descriptor() ([]byte, []int) { + return file_spec_proto_extension_v1_phone_phone_proto_rawDescGZIP(), []int{0} +} + +func (x *SendVoiceWithTemplateRequest) GetComponentName() string { + if x != nil { + return x.ComponentName + } + return "" +} + +func (x *SendVoiceWithTemplateRequest) GetTemplate() *VoiceTemplate { + if x != nil { + return x.Template + } + return nil +} + +func (x *SendVoiceWithTemplateRequest) GetToMobile() []string { + if x != nil { + return x.ToMobile + } + return nil +} + +func (x *SendVoiceWithTemplateRequest) GetFromMobile() string { + if x != nil { + return x.FromMobile + } + return "" +} + +// VoiceTemplate +type VoiceTemplate struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Required + TemplateId string `protobuf:"bytes,1,opt,name=template_id,json=templateId,proto3" json:"template_id,omitempty"` + // Required + TemplateParams map[string]string `protobuf:"bytes,2,rep,name=template_params,json=templateParams,proto3" json:"template_params,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *VoiceTemplate) Reset() { + *x = VoiceTemplate{} + if protoimpl.UnsafeEnabled { + mi := &file_spec_proto_extension_v1_phone_phone_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *VoiceTemplate) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*VoiceTemplate) ProtoMessage() {} + +func (x *VoiceTemplate) ProtoReflect() protoreflect.Message { + mi := &file_spec_proto_extension_v1_phone_phone_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use VoiceTemplate.ProtoReflect.Descriptor instead. +func (*VoiceTemplate) Descriptor() ([]byte, []int) { + return file_spec_proto_extension_v1_phone_phone_proto_rawDescGZIP(), []int{1} +} + +func (x *VoiceTemplate) GetTemplateId() string { + if x != nil { + return x.TemplateId + } + return "" +} + +func (x *VoiceTemplate) GetTemplateParams() map[string]string { + if x != nil { + return x.TemplateParams + } + return nil +} + +// The response of `SendVoiceWithTemplate` method +type SendVoiceWithTemplateResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Id of this request. + RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` +} + +func (x *SendVoiceWithTemplateResponse) Reset() { + *x = SendVoiceWithTemplateResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_spec_proto_extension_v1_phone_phone_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SendVoiceWithTemplateResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SendVoiceWithTemplateResponse) ProtoMessage() {} + +func (x *SendVoiceWithTemplateResponse) ProtoReflect() protoreflect.Message { + mi := &file_spec_proto_extension_v1_phone_phone_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SendVoiceWithTemplateResponse.ProtoReflect.Descriptor instead. +func (*SendVoiceWithTemplateResponse) Descriptor() ([]byte, []int) { + return file_spec_proto_extension_v1_phone_phone_proto_rawDescGZIP(), []int{2} +} + +func (x *SendVoiceWithTemplateResponse) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +var File_spec_proto_extension_v1_phone_phone_proto protoreflect.FileDescriptor + +var file_spec_proto_extension_v1_phone_phone_proto_rawDesc = []byte{ + 0x0a, 0x29, 0x73, 0x70, 0x65, 0x63, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x74, + 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x2f, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x2f, + 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1d, 0x73, 0x70, 0x65, + 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, + 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x22, 0xcd, 0x01, 0x0a, 0x1c, 0x53, + 0x65, 0x6e, 0x64, 0x56, 0x6f, 0x69, 0x63, 0x65, 0x57, 0x69, 0x74, 0x68, 0x54, 0x65, 0x6d, 0x70, + 0x6c, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x63, + 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0d, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x4e, 0x61, + 0x6d, 0x65, 0x12, 0x48, 0x0a, 0x08, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x73, 0x70, 0x65, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x70, + 0x68, 0x6f, 0x6e, 0x65, 0x2e, 0x56, 0x6f, 0x69, 0x63, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, + 0x74, 0x65, 0x52, 0x08, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x12, 0x1b, 0x0a, 0x09, + 0x74, 0x6f, 0x5f, 0x6d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x08, 0x74, 0x6f, 0x4d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x66, 0x72, 0x6f, + 0x6d, 0x5f, 0x6d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, + 0x66, 0x72, 0x6f, 0x6d, 0x4d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x22, 0xde, 0x01, 0x0a, 0x0d, 0x56, + 0x6f, 0x69, 0x63, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x12, 0x1f, 0x0a, 0x0b, + 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0a, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x49, 0x64, 0x12, 0x69, 0x0a, + 0x0f, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, + 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x40, 0x2e, 0x73, 0x70, 0x65, 0x63, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, + 0x2e, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x2e, 0x56, 0x6f, 0x69, 0x63, 0x65, 0x54, 0x65, 0x6d, 0x70, + 0x6c, 0x61, 0x74, 0x65, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, + 0x61, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0e, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, + 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x41, 0x0a, 0x13, 0x54, 0x65, 0x6d, 0x70, + 0x6c, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, + 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, + 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x3e, 0x0a, 0x1d, 0x53, + 0x65, 0x6e, 0x64, 0x56, 0x6f, 0x69, 0x63, 0x65, 0x57, 0x69, 0x74, 0x68, 0x54, 0x65, 0x6d, 0x70, + 0x6c, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, + 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x32, 0xa9, 0x01, 0x0a, 0x10, + 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x43, 0x61, 0x6c, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x12, 0x94, 0x01, 0x0a, 0x15, 0x53, 0x65, 0x6e, 0x64, 0x56, 0x6f, 0x69, 0x63, 0x65, 0x57, 0x69, + 0x74, 0x68, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x12, 0x3b, 0x2e, 0x73, 0x70, 0x65, + 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, + 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x56, + 0x6f, 0x69, 0x63, 0x65, 0x57, 0x69, 0x74, 0x68, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3c, 0x2e, 0x73, 0x70, 0x65, 0x63, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x76, + 0x31, 0x2e, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x56, 0x6f, 0x69, 0x63, + 0x65, 0x57, 0x69, 0x74, 0x68, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x35, 0x5a, 0x33, 0x6d, 0x6f, 0x73, 0x6e, 0x2e, + 0x69, 0x6f, 0x2f, 0x6c, 0x61, 0x79, 0x6f, 0x74, 0x74, 0x6f, 0x2f, 0x73, 0x70, 0x65, 0x63, 0x2f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x2f, + 0x76, 0x31, 0x2f, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x3b, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_spec_proto_extension_v1_phone_phone_proto_rawDescOnce sync.Once + file_spec_proto_extension_v1_phone_phone_proto_rawDescData = file_spec_proto_extension_v1_phone_phone_proto_rawDesc +) + +func file_spec_proto_extension_v1_phone_phone_proto_rawDescGZIP() []byte { + file_spec_proto_extension_v1_phone_phone_proto_rawDescOnce.Do(func() { + file_spec_proto_extension_v1_phone_phone_proto_rawDescData = protoimpl.X.CompressGZIP(file_spec_proto_extension_v1_phone_phone_proto_rawDescData) + }) + return file_spec_proto_extension_v1_phone_phone_proto_rawDescData +} + +var file_spec_proto_extension_v1_phone_phone_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_spec_proto_extension_v1_phone_phone_proto_goTypes = []interface{}{ + (*SendVoiceWithTemplateRequest)(nil), // 0: spec.proto.extension.v1.phone.SendVoiceWithTemplateRequest + (*VoiceTemplate)(nil), // 1: spec.proto.extension.v1.phone.VoiceTemplate + (*SendVoiceWithTemplateResponse)(nil), // 2: spec.proto.extension.v1.phone.SendVoiceWithTemplateResponse + nil, // 3: spec.proto.extension.v1.phone.VoiceTemplate.TemplateParamsEntry +} +var file_spec_proto_extension_v1_phone_phone_proto_depIdxs = []int32{ + 1, // 0: spec.proto.extension.v1.phone.SendVoiceWithTemplateRequest.template:type_name -> spec.proto.extension.v1.phone.VoiceTemplate + 3, // 1: spec.proto.extension.v1.phone.VoiceTemplate.template_params:type_name -> spec.proto.extension.v1.phone.VoiceTemplate.TemplateParamsEntry + 0, // 2: spec.proto.extension.v1.phone.PhoneCallService.SendVoiceWithTemplate:input_type -> spec.proto.extension.v1.phone.SendVoiceWithTemplateRequest + 2, // 3: spec.proto.extension.v1.phone.PhoneCallService.SendVoiceWithTemplate:output_type -> spec.proto.extension.v1.phone.SendVoiceWithTemplateResponse + 3, // [3:4] is the sub-list for method output_type + 2, // [2:3] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_spec_proto_extension_v1_phone_phone_proto_init() } +func file_spec_proto_extension_v1_phone_phone_proto_init() { + if File_spec_proto_extension_v1_phone_phone_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_spec_proto_extension_v1_phone_phone_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SendVoiceWithTemplateRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_spec_proto_extension_v1_phone_phone_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*VoiceTemplate); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_spec_proto_extension_v1_phone_phone_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SendVoiceWithTemplateResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_spec_proto_extension_v1_phone_phone_proto_rawDesc, + NumEnums: 0, + NumMessages: 4, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_spec_proto_extension_v1_phone_phone_proto_goTypes, + DependencyIndexes: file_spec_proto_extension_v1_phone_phone_proto_depIdxs, + MessageInfos: file_spec_proto_extension_v1_phone_phone_proto_msgTypes, + }.Build() + File_spec_proto_extension_v1_phone_phone_proto = out.File + file_spec_proto_extension_v1_phone_phone_proto_rawDesc = nil + file_spec_proto_extension_v1_phone_phone_proto_goTypes = nil + file_spec_proto_extension_v1_phone_phone_proto_depIdxs = nil +} diff --git a/spec/proto/extension/v1/phone/phone.proto b/spec/proto/extension/v1/phone/phone.proto index 6e683f2e5d..b63f7cd465 100644 --- a/spec/proto/extension/v1/phone/phone.proto +++ b/spec/proto/extension/v1/phone/phone.proto @@ -4,7 +4,6 @@ package spec.proto.extension.v1.phone; option go_package = "mosn.io/layotto/spec/proto/extension/v1/phone;phone"; -/* @exclude quickstart generator */ // PhoneCallService is one of Notify APIs. It's used to send voice messages service PhoneCallService { diff --git a/spec/proto/extension/v1/phone/phone_grpc.pb.go b/spec/proto/extension/v1/phone/phone_grpc.pb.go new file mode 100644 index 0000000000..b43fecf4f1 --- /dev/null +++ b/spec/proto/extension/v1/phone/phone_grpc.pb.go @@ -0,0 +1,102 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. + +package phone + +import ( + context "context" + + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// PhoneCallServiceClient is the client API for PhoneCallService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type PhoneCallServiceClient interface { + // Send voice using the specific template + SendVoiceWithTemplate(ctx context.Context, in *SendVoiceWithTemplateRequest, opts ...grpc.CallOption) (*SendVoiceWithTemplateResponse, error) +} + +type phoneCallServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewPhoneCallServiceClient(cc grpc.ClientConnInterface) PhoneCallServiceClient { + return &phoneCallServiceClient{cc} +} + +func (c *phoneCallServiceClient) SendVoiceWithTemplate(ctx context.Context, in *SendVoiceWithTemplateRequest, opts ...grpc.CallOption) (*SendVoiceWithTemplateResponse, error) { + out := new(SendVoiceWithTemplateResponse) + err := c.cc.Invoke(ctx, "/spec.proto.extension.v1.phone.PhoneCallService/SendVoiceWithTemplate", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// PhoneCallServiceServer is the server API for PhoneCallService service. +// All implementations should embed UnimplementedPhoneCallServiceServer +// for forward compatibility +type PhoneCallServiceServer interface { + // Send voice using the specific template + SendVoiceWithTemplate(context.Context, *SendVoiceWithTemplateRequest) (*SendVoiceWithTemplateResponse, error) +} + +// UnimplementedPhoneCallServiceServer should be embedded to have forward compatible implementations. +type UnimplementedPhoneCallServiceServer struct { +} + +func (UnimplementedPhoneCallServiceServer) SendVoiceWithTemplate(context.Context, *SendVoiceWithTemplateRequest) (*SendVoiceWithTemplateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendVoiceWithTemplate not implemented") +} + +// UnsafePhoneCallServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to PhoneCallServiceServer will +// result in compilation errors. +type UnsafePhoneCallServiceServer interface { + mustEmbedUnimplementedPhoneCallServiceServer() +} + +func RegisterPhoneCallServiceServer(s grpc.ServiceRegistrar, srv PhoneCallServiceServer) { + s.RegisterService(&PhoneCallService_ServiceDesc, srv) +} + +func _PhoneCallService_SendVoiceWithTemplate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SendVoiceWithTemplateRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PhoneCallServiceServer).SendVoiceWithTemplate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/spec.proto.extension.v1.phone.PhoneCallService/SendVoiceWithTemplate", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PhoneCallServiceServer).SendVoiceWithTemplate(ctx, req.(*SendVoiceWithTemplateRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// PhoneCallService_ServiceDesc is the grpc.ServiceDesc for PhoneCallService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var PhoneCallService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "spec.proto.extension.v1.phone.PhoneCallService", + HandlerType: (*PhoneCallServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "SendVoiceWithTemplate", + Handler: _PhoneCallService_SendVoiceWithTemplate_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "spec/proto/extension/v1/phone/phone.proto", +} diff --git a/spec/proto/extension/v1/s3/oss.pb.go b/spec/proto/extension/v1/s3/oss.pb.go index f7b95045ef..e6a55c6a19 100644 --- a/spec/proto/extension/v1/s3/oss.pb.go +++ b/spec/proto/extension/v1/s3/oss.pb.go @@ -7776,7 +7776,10 @@ var file_oss_proto_rawDesc = []byte{ 0x2f, 0x2e, 0x73, 0x70, 0x65, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x33, 0x2e, 0x52, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, - 0x22, 0x00, 0x42, 0x2f, 0x5a, 0x2d, 0x6d, 0x6f, 0x73, 0x6e, 0x2e, 0x69, 0x6f, 0x2f, 0x6c, 0x61, + 0x22, 0x00, 0x42, 0x5f, 0x0a, 0x1a, 0x73, 0x70, 0x65, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x2e, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x33, + 0x42, 0x12, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x50, + 0x72, 0x6f, 0x74, 0x6f, 0x5a, 0x2d, 0x6d, 0x6f, 0x73, 0x6e, 0x2e, 0x69, 0x6f, 0x2f, 0x6c, 0x61, 0x79, 0x6f, 0x74, 0x74, 0x6f, 0x2f, 0x73, 0x70, 0x65, 0x63, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x33, 0x3b, 0x73, 0x33, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, From 5f65f473b7b4dfc06deef65994371119e57fb637 Mon Sep 17 00:00:00 2001 From: seeflood Date: Wed, 14 Sep 2022 18:15:55 +0800 Subject: [PATCH 2/5] fix: examples errors (#787) Signed-off-by: seeflood --- configs/config.json | 2 +- configs/config_apollo.json | 2 +- configs/config_consul.json | 2 +- configs/config_file.json | 2 +- configs/config_file_qiniu_oss.json | 2 +- configs/config_file_tencentcloud_oss.json | 2 +- configs/config_mongo.json | 2 +- configs/config_redis.json | 2 +- configs/config_standalone.json | 2 +- configs/config_trace_jaeger.json | 2 +- configs/config_trace_skywalking.json | 2 +- configs/config_trace_zipkin.json | 2 +- configs/config_zookeeper.json | 2 +- configs/runtime_config.json | 2 +- demo/flowcontrol/client.go | 2 +- demo/lifecycle/common/client.go | 6 +++--- deploy/k8s/sidecar/default_quickstart_counter.yaml | 2 +- deploy/k8s/standalone/default_configmap.yaml | 2 +- deploy/k8s/standalone/default_quickstart.yaml | 2 +- docker/layotto-etcd/etcd_config.json | 2 +- docker/layotto-minio/config_minio.json | 2 +- docker/layotto-redis/config_redis.json | 2 +- docs/en/start/email/start.md | 4 ++-- docs/en/start/lifecycle/start.md | 4 ++-- docs/en/start/oss/start.md | 4 ++-- docs/en/start/phone/start.md | 4 ++-- docs/en/start/pubsub/start.md | 6 +++--- docs/en/start/sequencer/start.md | 4 ++-- docs/en/start/state/start.md | 4 ++-- docs/template/quickstart.tmpl | 4 ++-- docs/template/quickstart_zh.tmpl | 4 ++-- docs/zh/design/actuator/grpc-design-doc.md | 2 +- docs/zh/start/email/start.md | 4 ++-- docs/zh/start/lifecycle/start.md | 4 ++-- docs/zh/start/phone/start.md | 4 ++-- docs/zh/start/pubsub/start.md | 6 +++--- docs/zh/start/sequencer/start.md | 4 ++-- docs/zh/start/state/start.md | 4 ++-- sdk/go-sdk/test/runtime/redis_integrate_test.go | 2 +- 39 files changed, 58 insertions(+), 58 deletions(-) diff --git a/configs/config.json b/configs/config.json index 0f2ba607e2..8fa353a654 100644 --- a/configs/config.json +++ b/configs/config.json @@ -22,7 +22,7 @@ "server_name": "runtime", "grpc_config": { "hellos": { - "quick_start_demo": { + "helloworld": { "type": "helloworld", "hello": "greeting" } diff --git a/configs/config_apollo.json b/configs/config_apollo.json index cc9b358877..89e03a61f2 100644 --- a/configs/config_apollo.json +++ b/configs/config_apollo.json @@ -29,7 +29,7 @@ "server_name": "runtime", "grpc_config": { "hellos": { - "quick_start_demo": { + "helloworld": { "type": "helloworld", "hello": "greeting" } diff --git a/configs/config_consul.json b/configs/config_consul.json index 673fc04514..3d62f7f794 100644 --- a/configs/config_consul.json +++ b/configs/config_consul.json @@ -22,7 +22,7 @@ "server_name": "runtime", "grpc_config": { "hellos": { - "quick_start_demo": { + "helloworld": { "type": "helloworld", "hello": "greeting" } diff --git a/configs/config_file.json b/configs/config_file.json index 8cf2cb13eb..6f1cbb9e2e 100644 --- a/configs/config_file.json +++ b/configs/config_file.json @@ -17,7 +17,7 @@ "server_name": "runtime", "grpc_config": { "hellos": { - "quick_start_demo": { + "helloworld": { "type": "helloworld", "hello": "greeting" } diff --git a/configs/config_file_qiniu_oss.json b/configs/config_file_qiniu_oss.json index 4e1d7ea38e..0cd2439cdc 100644 --- a/configs/config_file_qiniu_oss.json +++ b/configs/config_file_qiniu_oss.json @@ -17,7 +17,7 @@ "server_name": "runtime", "grpc_config": { "hellos": { - "quick_start_demo": { + "helloworld": { "type": "helloworld", "hello": "greeting" } diff --git a/configs/config_file_tencentcloud_oss.json b/configs/config_file_tencentcloud_oss.json index c57c8dafae..c825255697 100644 --- a/configs/config_file_tencentcloud_oss.json +++ b/configs/config_file_tencentcloud_oss.json @@ -17,7 +17,7 @@ "server_name": "runtime", "grpc_config": { "hellos": { - "quick_start_demo": { + "helloworld": { "type": "helloworld", "hello": "greeting" } diff --git a/configs/config_mongo.json b/configs/config_mongo.json index 2cc0e621bd..366f749bdf 100644 --- a/configs/config_mongo.json +++ b/configs/config_mongo.json @@ -22,7 +22,7 @@ "server_name": "runtime", "grpc_config": { "hellos": { - "quick_start_demo": { + "helloworld": { "type": "helloworld", "hello": "greeting" } diff --git a/configs/config_redis.json b/configs/config_redis.json index c4db395101..7dc6736920 100644 --- a/configs/config_redis.json +++ b/configs/config_redis.json @@ -22,7 +22,7 @@ "server_name": "runtime", "grpc_config": { "hellos": { - "quick_start_demo": { + "helloworld": { "type": "helloworld", "hello": "greeting" } diff --git a/configs/config_standalone.json b/configs/config_standalone.json index 5e83dd51d6..2ec7ca4a66 100644 --- a/configs/config_standalone.json +++ b/configs/config_standalone.json @@ -22,7 +22,7 @@ "server_name": "runtime", "grpc_config": { "hellos": { - "quick_start_demo": { + "helloworld": { "type": "helloworld", "hello": "greeting" } diff --git a/configs/config_trace_jaeger.json b/configs/config_trace_jaeger.json index a79492890f..5ee7b2471d 100644 --- a/configs/config_trace_jaeger.json +++ b/configs/config_trace_jaeger.json @@ -17,7 +17,7 @@ "server_name": "runtime", "grpc_config": { "hellos": { - "quick_start_demo": { + "helloworld": { "type": "helloworld", "hello": "greeting" } diff --git a/configs/config_trace_skywalking.json b/configs/config_trace_skywalking.json index e72c875bed..10b4873bab 100644 --- a/configs/config_trace_skywalking.json +++ b/configs/config_trace_skywalking.json @@ -17,7 +17,7 @@ "server_name": "runtime", "grpc_config": { "hellos": { - "quick_start_demo": { + "helloworld": { "type": "helloworld", "hello": "greeting" } diff --git a/configs/config_trace_zipkin.json b/configs/config_trace_zipkin.json index 46362df280..bbb2a467de 100644 --- a/configs/config_trace_zipkin.json +++ b/configs/config_trace_zipkin.json @@ -17,7 +17,7 @@ "server_name": "runtime", "grpc_config": { "hellos": { - "quick_start_demo": { + "helloworld": { "type": "helloworld", "hello": "greeting" } diff --git a/configs/config_zookeeper.json b/configs/config_zookeeper.json index 2829a8b6a9..3a3c2e7eed 100644 --- a/configs/config_zookeeper.json +++ b/configs/config_zookeeper.json @@ -22,7 +22,7 @@ "server_name": "runtime", "grpc_config": { "hellos": { - "quick_start_demo": { + "helloworld": { "type": "helloworld", "hello": "greeting" } diff --git a/configs/runtime_config.json b/configs/runtime_config.json index 2d72c76289..bc47750e2b 100644 --- a/configs/runtime_config.json +++ b/configs/runtime_config.json @@ -17,7 +17,7 @@ "server_name": "runtime", "grpc_config": { "hellos": { - "quick_start_demo": { + "helloworld": { "type": "helloworld", "hello": "greeting" } diff --git a/demo/flowcontrol/client.go b/demo/flowcontrol/client.go index 870abc07ca..3cf7253fe2 100644 --- a/demo/flowcontrol/client.go +++ b/demo/flowcontrol/client.go @@ -36,7 +36,7 @@ func main() { for i := 0; i < 10; i++ { r, err := c.SayHello(context.Background(), &runtimev1pb.SayHelloRequest{ - ServiceName: "quick_start_demo", + ServiceName: "helloworld", }) if err != nil { fmt.Println("get an error: ", err) diff --git a/demo/lifecycle/common/client.go b/demo/lifecycle/common/client.go index 004e5de1a3..05b107923c 100644 --- a/demo/lifecycle/common/client.go +++ b/demo/lifecycle/common/client.go @@ -17,7 +17,7 @@ func main() { // 1. invoke sayHello API client := runtimev1pb.NewRuntimeClient(conn) hello, err := client.SayHello(context.Background(), &runtimev1pb.SayHelloRequest{ - ServiceName: "quick_start_demo", + ServiceName: "helloworld", Name: "eva", }) if err != nil { @@ -36,7 +36,7 @@ func main() { metaData["hello"] = "goodbye" req := &runtimev1pb.DynamicConfiguration{ComponentConfig: &runtimev1pb.ComponentConfig{ Kind: "hellos", - Name: "quick_start_demo", + Name: "helloworld", Metadata: metaData, }} _, err = c.ApplyConfiguration(context.Background(), req) @@ -46,7 +46,7 @@ func main() { // 3. invoke sayHello API again client = runtimev1pb.NewRuntimeClient(conn) hello, err = client.SayHello(context.Background(), &runtimev1pb.SayHelloRequest{ - ServiceName: "quick_start_demo", + ServiceName: "helloworld", Name: "eva", }) if err != nil { diff --git a/deploy/k8s/sidecar/default_quickstart_counter.yaml b/deploy/k8s/sidecar/default_quickstart_counter.yaml index 45dea2bcee..4e57acb155 100644 --- a/deploy/k8s/sidecar/default_quickstart_counter.yaml +++ b/deploy/k8s/sidecar/default_quickstart_counter.yaml @@ -28,7 +28,7 @@ data: "server_name": "runtime", "grpc_config": { "hellos": { - "quick_start_demo": { + "helloworld": { "type": "helloworld", "hello": "greeting" } diff --git a/deploy/k8s/standalone/default_configmap.yaml b/deploy/k8s/standalone/default_configmap.yaml index 20fb1587fc..a0a6c4b108 100644 --- a/deploy/k8s/standalone/default_configmap.yaml +++ b/deploy/k8s/standalone/default_configmap.yaml @@ -28,7 +28,7 @@ data: "server_name": "runtime", "grpc_config": { "hellos": { - "quick_start_demo": { + "helloworld": { "type": "helloworld", "hello": "greeting" } diff --git a/deploy/k8s/standalone/default_quickstart.yaml b/deploy/k8s/standalone/default_quickstart.yaml index 58cda42893..4179b6e6a3 100644 --- a/deploy/k8s/standalone/default_quickstart.yaml +++ b/deploy/k8s/standalone/default_quickstart.yaml @@ -28,7 +28,7 @@ data: "server_name": "runtime", "grpc_config": { "hellos": { - "quick_start_demo": { + "helloworld": { "type": "helloworld", "hello": "greeting" } diff --git a/docker/layotto-etcd/etcd_config.json b/docker/layotto-etcd/etcd_config.json index 864913680d..1a23beba51 100644 --- a/docker/layotto-etcd/etcd_config.json +++ b/docker/layotto-etcd/etcd_config.json @@ -17,7 +17,7 @@ "server_name": "runtime", "grpc_config": { "hellos": { - "quick_start_demo": { + "helloworld": { "type": "helloworld", "hello": "greeting" } diff --git a/docker/layotto-minio/config_minio.json b/docker/layotto-minio/config_minio.json index 33dae046b2..8042e6e137 100644 --- a/docker/layotto-minio/config_minio.json +++ b/docker/layotto-minio/config_minio.json @@ -17,7 +17,7 @@ "server_name": "runtime", "grpc_config": { "hellos": { - "quick_start_demo": { + "helloworld": { "type": "helloworld", "hello": "greeting" } diff --git a/docker/layotto-redis/config_redis.json b/docker/layotto-redis/config_redis.json index 6e82c5a93a..894b5dba54 100644 --- a/docker/layotto-redis/config_redis.json +++ b/docker/layotto-redis/config_redis.json @@ -22,7 +22,7 @@ "server_name": "runtime", "grpc_config": { "hellos": { - "quick_start_demo": { + "helloworld": { "type": "helloworld", "hello": "greeting" } diff --git a/docs/en/start/email/start.md b/docs/en/start/email/start.md index 3048223646..496354c810 100644 --- a/docs/en/start/email/start.md +++ b/docs/en/start/email/start.md @@ -71,7 +71,7 @@ cd java-sdk Build the demo: -```shell @if.not.exist examples-email/target/examples-email-1.1.0-jar-with-dependencies.jar +```shell @if.not.exist examples-email/target/examples-email-jar-with-dependencies.jar # build example jar mvn -f examples-email/pom.xml clean package ``` @@ -79,7 +79,7 @@ mvn -f examples-email/pom.xml clean package Run it: ```shell -java -jar examples-email/target/examples-email-1.1.0-jar-with-dependencies.jar +java -jar examples-email/target/examples-email-jar-with-dependencies.jar ``` If the following information is printed, the demo is successful: diff --git a/docs/en/start/lifecycle/start.md b/docs/en/start/lifecycle/start.md index 46329565b0..dbedb4a97f 100644 --- a/docs/en/start/lifecycle/start.md +++ b/docs/en/start/lifecycle/start.md @@ -76,7 +76,7 @@ TODO [comment]: <> (Build the demo:) -[comment]: <> (```shell @if.not.exist examples-lifecycle/target/examples-lifecycle-1.1.0-jar-with-dependencies.jar) +[comment]: <> (```shell @if.not.exist examples-lifecycle/target/examples-lifecycle-jar-with-dependencies.jar) [comment]: <> (# build example jar) @@ -88,7 +88,7 @@ TODO [comment]: <> (```shell) -[comment]: <> (java -jar examples-lifecycle/target/examples-lifecycle-1.1.0-jar-with-dependencies.jar) +[comment]: <> (java -jar examples-lifecycle/target/examples-lifecycle-jar-with-dependencies.jar) [comment]: <> (```) diff --git a/docs/en/start/oss/start.md b/docs/en/start/oss/start.md index ee74618289..86bfca9920 100644 --- a/docs/en/start/oss/start.md +++ b/docs/en/start/oss/start.md @@ -100,7 +100,7 @@ cd java-sdk Build the demo: -```shell @if.not.exist examples-oss/target/examples-oss-1.1.0-jar-with-dependencies.jar +```shell @if.not.exist examples-oss/target/examples-oss-jar-with-dependencies.jar # build example jar mvn -f examples-oss/pom.xml clean package ``` @@ -108,7 +108,7 @@ mvn -f examples-oss/pom.xml clean package Run it: ```shell -java -jar examples-oss/target/examples-oss-1.1.0-jar-with-dependencies.jar +java -jar examples-oss/target/examples-oss-jar-with-dependencies.jar ``` If the following information is printed, the demo is successful: diff --git a/docs/en/start/phone/start.md b/docs/en/start/phone/start.md index 686d7a9334..9bf0967280 100644 --- a/docs/en/start/phone/start.md +++ b/docs/en/start/phone/start.md @@ -71,7 +71,7 @@ cd java-sdk Build the demo: -```shell @if.not.exist examples-phone/target/examples-phone-1.1.0-jar-with-dependencies.jar +```shell @if.not.exist examples-phone/target/examples-phone-jar-with-dependencies.jar # build example jar mvn -f examples-phone/pom.xml clean package ``` @@ -79,7 +79,7 @@ mvn -f examples-phone/pom.xml clean package Run it: ```shell -java -jar examples-phone/target/examples-phone-1.1.0-jar-with-dependencies.jar +java -jar examples-phone/target/examples-phone-jar-with-dependencies.jar ``` If the following information is printed, the demo is successful: diff --git a/docs/en/start/pubsub/start.md b/docs/en/start/pubsub/start.md index 7a49f07266..1670fb4f08 100644 --- a/docs/en/start/pubsub/start.md +++ b/docs/en/start/pubsub/start.md @@ -47,7 +47,7 @@ Build and run it: # build example jar mvn -f examples-pubsub-subscriber/pom.xml clean package # run the example -java -jar examples-pubsub-subscriber/target/examples-pubsub-subscriber-1.1.0-jar-with-dependencies.jar +java -jar examples-pubsub-subscriber/target/examples-pubsub-subscriber-jar-with-dependencies.jar ``` @@ -145,7 +145,7 @@ cd java-sdk Build: -```shell @if.not.exist examples-pubsub-publisher/target/examples-pubsub-publisher-1.1.0-jar-with-dependencies.jar +```shell @if.not.exist examples-pubsub-publisher/target/examples-pubsub-publisher-jar-with-dependencies.jar # build example jar mvn -f examples-pubsub-publisher/pom.xml clean package ``` @@ -154,7 +154,7 @@ Run it: ```shell # run the example -java -jar examples-pubsub-publisher/target/examples-pubsub-publisher-1.1.0-jar-with-dependencies.jar +java -jar examples-pubsub-publisher/target/examples-pubsub-publisher-jar-with-dependencies.jar ``` diff --git a/docs/en/start/sequencer/start.md b/docs/en/start/sequencer/start.md index cf07238781..6870230653 100644 --- a/docs/en/start/sequencer/start.md +++ b/docs/en/start/sequencer/start.md @@ -104,7 +104,7 @@ cd java-sdk Build the demo: -```shell @if.not.exist examples-sequencer/target/examples-sequencer-1.1.0-jar-with-dependencies.jar +```shell @if.not.exist examples-sequencer/target/examples-sequencer-jar-with-dependencies.jar # build example jar mvn -f examples-sequencer/pom.xml clean package ``` @@ -112,7 +112,7 @@ mvn -f examples-sequencer/pom.xml clean package Run it: ```shell -java -jar examples-sequencer/target/examples-sequencer-1.1.0-jar-with-dependencies.jar +java -jar examples-sequencer/target/examples-sequencer-jar-with-dependencies.jar ``` If the following information is printed, the demo is successful: diff --git a/docs/en/start/state/start.md b/docs/en/start/state/start.md index ed289e3bcb..a54113e73d 100644 --- a/docs/en/start/state/start.md +++ b/docs/en/start/state/start.md @@ -127,7 +127,7 @@ cd java-sdk Build the demo: -```shell @if.not.exist examples-state/target/examples-state-1.1.0-jar-with-dependencies.jar +```shell @if.not.exist examples-state/target/examples-state-jar-with-dependencies.jar # build example jar mvn -f examples-state/pom.xml clean package ``` @@ -135,7 +135,7 @@ mvn -f examples-state/pom.xml clean package Run it: ``` -java -jar examples-state/target/examples-state-1.1.0-jar-with-dependencies.jar +java -jar examples-state/target/examples-state-jar-with-dependencies.jar ``` The demo will print the following message: diff --git a/docs/template/quickstart.tmpl b/docs/template/quickstart.tmpl index d4073f4977..8ccb7c009b 100644 --- a/docs/template/quickstart.tmpl +++ b/docs/template/quickstart.tmpl @@ -71,7 +71,7 @@ cd java-sdk Build the demo: -```shell @if.not.exist examples-{{$file_name}}/target/examples-{{$file_name}}-1.1.0-jar-with-dependencies.jar +```shell @if.not.exist examples-{{$file_name}}/target/examples-{{$file_name}}-jar-with-dependencies.jar # build example jar mvn -f examples-{{$file_name}}/pom.xml clean package ``` @@ -79,7 +79,7 @@ mvn -f examples-{{$file_name}}/pom.xml clean package Run it: ```shell -java -jar examples-{{$file_name}}/target/examples-{{$file_name}}-1.1.0-jar-with-dependencies.jar +java -jar examples-{{$file_name}}/target/examples-{{$file_name}}-jar-with-dependencies.jar ``` If the following information is printed, the demo is successful: diff --git a/docs/template/quickstart_zh.tmpl b/docs/template/quickstart_zh.tmpl index d7d275aade..0aa527850f 100644 --- a/docs/template/quickstart_zh.tmpl +++ b/docs/template/quickstart_zh.tmpl @@ -71,7 +71,7 @@ cd java-sdk 构建 examples: -```shell @if.not.exist examples-{{$file_name}}/target/examples-{{$file_name}}-1.1.0-jar-with-dependencies.jar +```shell @if.not.exist examples-{{$file_name}}/target/examples-{{$file_name}}-jar-with-dependencies.jar # build example jar mvn -f examples-{{$file_name}}/pom.xml clean package ``` @@ -79,7 +79,7 @@ mvn -f examples-{{$file_name}}/pom.xml clean package 运行: ```shell -java -jar examples-{{$file_name}}/target/examples-{{$file_name}}-1.1.0-jar-with-dependencies.jar +java -jar examples-{{$file_name}}/target/examples-{{$file_name}}-jar-with-dependencies.jar ``` 打印出以下信息说明运行成功: diff --git a/docs/zh/design/actuator/grpc-design-doc.md b/docs/zh/design/actuator/grpc-design-doc.md index 0071a48987..55b76a3fd8 100644 --- a/docs/zh/design/actuator/grpc-design-doc.md +++ b/docs/zh/design/actuator/grpc-design-doc.md @@ -72,7 +72,7 @@ func MyFunc(_ json.RawMessage) *grpc.Server { "server_name":"runtime", "grpc_config": { "hellos": { - "quick_start_demo": { + "helloworld": { "type": "helloworld", "hello": "greeting" } diff --git a/docs/zh/start/email/start.md b/docs/zh/start/email/start.md index f30ae55f5a..2716924aad 100644 --- a/docs/zh/start/email/start.md +++ b/docs/zh/start/email/start.md @@ -71,7 +71,7 @@ cd java-sdk 构建 examples: -```shell @if.not.exist examples-email/target/examples-email-1.1.0-jar-with-dependencies.jar +```shell @if.not.exist examples-email/target/examples-email-jar-with-dependencies.jar # build example jar mvn -f examples-email/pom.xml clean package ``` @@ -79,7 +79,7 @@ mvn -f examples-email/pom.xml clean package 运行: ```shell -java -jar examples-email/target/examples-email-1.1.0-jar-with-dependencies.jar +java -jar examples-email/target/examples-email-jar-with-dependencies.jar ``` 打印出以下信息说明运行成功: diff --git a/docs/zh/start/lifecycle/start.md b/docs/zh/start/lifecycle/start.md index e73e0cee01..8721f1ac4f 100644 --- a/docs/zh/start/lifecycle/start.md +++ b/docs/zh/start/lifecycle/start.md @@ -76,7 +76,7 @@ TODO [comment]: <> (构建 examples:) -[comment]: <> (```shell @if.not.exist examples-lifecycle/target/examples-lifecycle-1.1.0-jar-with-dependencies.jar) +[comment]: <> (```shell @if.not.exist examples-lifecycle/target/examples-lifecycle-jar-with-dependencies.jar) [comment]: <> (# build example jar) @@ -88,7 +88,7 @@ TODO [comment]: <> (```shell) -[comment]: <> (java -jar examples-lifecycle/target/examples-lifecycle-1.1.0-jar-with-dependencies.jar) +[comment]: <> (java -jar examples-lifecycle/target/examples-lifecycle-jar-with-dependencies.jar) [comment]: <> (```) diff --git a/docs/zh/start/phone/start.md b/docs/zh/start/phone/start.md index 72af36c21d..d73b03c8e5 100644 --- a/docs/zh/start/phone/start.md +++ b/docs/zh/start/phone/start.md @@ -71,7 +71,7 @@ cd java-sdk 构建 examples: -```shell @if.not.exist examples-phone/target/examples-phone-1.1.0-jar-with-dependencies.jar +```shell @if.not.exist examples-phone/target/examples-phone-jar-with-dependencies.jar # build example jar mvn -f examples-phone/pom.xml clean package ``` @@ -79,7 +79,7 @@ mvn -f examples-phone/pom.xml clean package 运行: ```shell -java -jar examples-phone/target/examples-phone-1.1.0-jar-with-dependencies.jar +java -jar examples-phone/target/examples-phone-jar-with-dependencies.jar ``` 打印出以下信息说明运行成功: diff --git a/docs/zh/start/pubsub/start.md b/docs/zh/start/pubsub/start.md index ba083ac491..0df36731da 100644 --- a/docs/zh/start/pubsub/start.md +++ b/docs/zh/start/pubsub/start.md @@ -50,7 +50,7 @@ cd java-sdk # build example jar mvn -f examples-pubsub-subscriber/pom.xml clean package # run the example -java -jar examples-pubsub-subscriber/target/examples-pubsub-subscriber-1.1.0-jar-with-dependencies.jar +java -jar examples-pubsub-subscriber/target/examples-pubsub-subscriber-jar-with-dependencies.jar ``` @@ -150,7 +150,7 @@ cd java-sdk 构建: -```shell @if.not.exist examples-pubsub-publisher/target/examples-pubsub-publisher-1.1.0-jar-with-dependencies.jar +```shell @if.not.exist examples-pubsub-publisher/target/examples-pubsub-publisher-jar-with-dependencies.jar # build example jar mvn -f examples-pubsub-publisher/pom.xml clean package ``` @@ -159,7 +159,7 @@ mvn -f examples-pubsub-publisher/pom.xml clean package ```shell # run the example -java -jar examples-pubsub-publisher/target/examples-pubsub-publisher-1.1.0-jar-with-dependencies.jar +java -jar examples-pubsub-publisher/target/examples-pubsub-publisher-jar-with-dependencies.jar ``` diff --git a/docs/zh/start/sequencer/start.md b/docs/zh/start/sequencer/start.md index 1e722cc9b9..e99e564ee3 100644 --- a/docs/zh/start/sequencer/start.md +++ b/docs/zh/start/sequencer/start.md @@ -110,7 +110,7 @@ cd java-sdk 构建: -```shell @if.not.exist examples-sequencer/target/examples-sequencer-1.1.0-jar-with-dependencies.jar +```shell @if.not.exist examples-sequencer/target/examples-sequencer-jar-with-dependencies.jar # build example jar mvn -f examples-sequencer/pom.xml clean package ``` @@ -118,7 +118,7 @@ mvn -f examples-sequencer/pom.xml clean package 运行: ```shell -java -jar examples-sequencer/target/examples-sequencer-1.1.0-jar-with-dependencies.jar +java -jar examples-sequencer/target/examples-sequencer-jar-with-dependencies.jar ``` 打印出以下信息说明运行成功: diff --git a/docs/zh/start/state/start.md b/docs/zh/start/state/start.md index d7968e84ec..9eb075c63f 100644 --- a/docs/zh/start/state/start.md +++ b/docs/zh/start/state/start.md @@ -129,7 +129,7 @@ cd java-sdk 构建: -```shell @if.not.exist examples-state/target/examples-state-1.1.0-jar-with-dependencies.jar +```shell @if.not.exist examples-state/target/examples-state-jar-with-dependencies.jar # build example jar mvn -f examples-state/pom.xml clean package ``` @@ -137,7 +137,7 @@ mvn -f examples-state/pom.xml clean package 运行: ``` -java -jar examples-state/target/examples-state-1.1.0-jar-with-dependencies.jar +java -jar examples-state/target/examples-state-jar-with-dependencies.jar ``` 打印出以下信息说明运行成功: diff --git a/sdk/go-sdk/test/runtime/redis_integrate_test.go b/sdk/go-sdk/test/runtime/redis_integrate_test.go index 0dd1c22c64..894efcf3cf 100644 --- a/sdk/go-sdk/test/runtime/redis_integrate_test.go +++ b/sdk/go-sdk/test/runtime/redis_integrate_test.go @@ -40,7 +40,7 @@ func TestHelloApi(t *testing.T) { ctx := context.Background() helloReq := &client.SayHelloRequest{ - ServiceName: "quick_start_demo", + ServiceName: "helloworld", } helloResp, err := cli.SayHello(ctx, helloReq) assert.Nil(t, err) From 6e086526abe6978d04e3c58bd37a2ee997c03603 Mon Sep 17 00:00:00 2001 From: Xunzhuo Date: Fri, 16 Sep 2022 16:22:38 +0800 Subject: [PATCH 3/5] fix: Incorrect conversion between integer types (#789) --- components/rpc/invoker/mosn/mosninvoker.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/rpc/invoker/mosn/mosninvoker.go b/components/rpc/invoker/mosn/mosninvoker.go index 7ef453b148..c85dc4e330 100644 --- a/components/rpc/invoker/mosn/mosninvoker.go +++ b/components/rpc/invoker/mosn/mosninvoker.go @@ -96,7 +96,7 @@ func (m *mosnInvoker) Invoke(ctx context.Context, req *rpc.RPCRequest) (resp *rp if req.Timeout == 0 { req.Timeout = rpc.DefaultRequestTimeoutMs if ts, ok := req.Header[rpc.RequestTimeoutMs]; ok && len(ts) > 0 { - t, err := strconv.Atoi(ts[0]) + t, err := strconv.ParseInt(ts[0], 10, 32) if err == nil && t != 0 { req.Timeout = int32(t) } From ef601441ac155aa9b0bd1eb044eb2fdcb7a058f7 Mon Sep 17 00:00:00 2001 From: Xunzhuo Date: Fri, 16 Sep 2022 16:47:14 +0800 Subject: [PATCH 4/5] chore: set deadlink validation to schedule, move out of PRs (#788) Co-authored-by: seeflood --- .github/workflows/dead-link-checker.yaml | 6 +++--- .github/workflows/stale.yml | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dead-link-checker.yaml b/.github/workflows/dead-link-checker.yaml index 081f11b245..1468485f6a 100644 --- a/.github/workflows/dead-link-checker.yaml +++ b/.github/workflows/dead-link-checker.yaml @@ -1,9 +1,9 @@ name: Layotto Env Pipeline 🌊 +# Deadlink Validation will auto run at 0:00 am everyday. on: - pull_request: - branches: - - main + schedule: + - cron: '0 0 * * *' jobs: check: diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 1ac40b6c81..c64e8ecb5e 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -1,4 +1,5 @@ name: Layotto Env Pipeline 🌊 + on: schedule: - cron: '30 1 * * *' From 3fb2ffd1f19ca7a14e5de93b2f9c7ef150b6d1a2 Mon Sep 17 00:00:00 2001 From: Xunzhuo Date: Fri, 16 Sep 2022 17:19:00 +0800 Subject: [PATCH 5/5] refactor: infra and cmds (#785) Co-authored-by: seeflood --- .github/workflows/dead-link-checker.yaml | 2 +- .github/workflows/layotto-ci.yml | 10 +- .github/workflows/layotto-release.yml | 10 +- .github/workflows/quickstart-checker.yml | 4 +- Makefile | 354 +----------------- .../api_reference/how_to_generate_api_doc.md | 8 +- docs/en/development/commands.md | 125 ++++--- .../api_reference/how_to_generate_api_doc.md | 8 +- docs/zh/development/commands.md | 125 ++++--- make/ci.mk | 46 +++ make/common.mk | 55 ++- make/deploy.mk | 18 + make/golang.mk | 43 ++- make/help.mk | 65 ++++ make/image.mk | 53 ++- make/proto.mk | 33 +- make/wasm.mk | 22 ++ 17 files changed, 519 insertions(+), 462 deletions(-) create mode 100644 make/help.mk diff --git a/.github/workflows/dead-link-checker.yaml b/.github/workflows/dead-link-checker.yaml index 1468485f6a..48be809aca 100644 --- a/.github/workflows/dead-link-checker.yaml +++ b/.github/workflows/dead-link-checker.yaml @@ -23,4 +23,4 @@ jobs: nohup docsify serve docs -p 3000 & - name: Check dead links in all the .md files - run: make style.deadlink + run: make deadlink diff --git a/.github/workflows/layotto-ci.yml b/.github/workflows/layotto-ci.yml index 616a0519ab..0411007ae2 100644 --- a/.github/workflows/layotto-ci.yml +++ b/.github/workflows/layotto-ci.yml @@ -30,7 +30,7 @@ jobs: go-version: 1.18.1 - name: Format Go run: | - make check.style + make workspace resolve-modules: name: "🌈️ Resolve Go Modules" runs-on: ubuntu-latest @@ -71,7 +71,7 @@ jobs: with: go-version: 1.18.1 - name: Go Unit Test - run: make check.unit + run: make test coverage: name: "🤔 Coverage Analysis" @@ -81,7 +81,7 @@ jobs: - name: Check out code uses: actions/checkout@v2 - name: Test Coverage - run: make style.coverage + run: make coverage - name: Post Coverage run: bash <(curl -s https://codecov.io/bash) @@ -97,7 +97,7 @@ jobs: - name: Check out code uses: actions/checkout@v2 - name: Run Integrate tests - run: make integrate.wasm + run: make integrate-wasm runtime-integrate: name: "⚙️ Integrate with Runtime" @@ -111,7 +111,7 @@ jobs: - name: Check out code uses: actions/checkout@v2 - name: Run Integrate tests - run: make integrate.runtime + run: make integrate-runtime build-binary-darwin-amd64-artifact: name: "🧳 Darwin AMD64 Artifact" diff --git a/.github/workflows/layotto-release.yml b/.github/workflows/layotto-release.yml index 7e4a3eff82..836ef65b34 100644 --- a/.github/workflows/layotto-release.yml +++ b/.github/workflows/layotto-release.yml @@ -17,7 +17,7 @@ jobs: go-version: 1.18.1 - name: Format Go run: | - make check.style + make workspace resolve-modules: name: "👀 Resolve Go Modules" @@ -60,7 +60,7 @@ jobs: with: go-version: 1.18.1 - name: Go Unit Test - run: make check.unit + run: make test coverage: name: "🤔 Coverage Analysis" @@ -70,7 +70,7 @@ jobs: - name: Check out code uses: actions/checkout@v2 - name: Test Coverage - run: make style.coverage + run: make coverage - name: Post Coverage run: bash <(curl -s https://codecov.io/bash) @@ -86,7 +86,7 @@ jobs: - name: Check out code uses: actions/checkout@v2 - name: Run Integrate tests - run: make integrate.wasm + run: make integrate-wasm runtime-integrate: name: "⚙️ Integrate with Runtime" @@ -100,7 +100,7 @@ jobs: - name: Check out code uses: actions/checkout@v2 - name: Run Integrate tests - run: make integrate.runtime + run: make integrate-runtime build-binary-darwin-amd64-artifact: name: "🧳 Darwin AMD64 Artifact" diff --git a/.github/workflows/quickstart-checker.yml b/.github/workflows/quickstart-checker.yml index fd9eae77e6..af1d83e034 100644 --- a/.github/workflows/quickstart-checker.yml +++ b/.github/workflows/quickstart-checker.yml @@ -42,7 +42,7 @@ jobs: fi - name: Test quickstart in Golang 1.14.13 - run: make style.quickstart + run: make quickstart - name: Set up Go 1.x uses: actions/setup-go@v2 @@ -50,4 +50,4 @@ jobs: go-version: 1.17.8 - name: Test quickstart in Golang 1.17.8 - run: make style.quickstart QUICKSTART_VERSION=1.17 + run: make quickstart QUICKSTART_VERSION=1.17 diff --git a/Makefile b/Makefile index d8b980204d..d1a044d991 100644 --- a/Makefile +++ b/Makefile @@ -11,337 +11,23 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Layotto commands 👀: - -# A fast and efficient cloud native application runtime 🚀. -# Commands below are used in Development 💻 and GitHub workflow 🌊. - -# Usage: make ... - -# COMMANDS: -# build Build layotto for host platform. -# build.multiarch Build layotto for multiple platforms. See option PLATFORMS. -# image Build docker images for host arch. -# image.multiarch Build docker images for multiple platforms. See option PLATFORMS. -# push Push docker images to registry. -# push.multiarch Push docker images for multiple platforms to registry. -# app Build app docker images for host arch. [`/docker/app` contains apps dockerfiles] -# app.multiarch Build app docker images for multiple platforms. See option PLATFORMS. -# wasm Build layotto wasm for linux arm64 platform. -# wasm.multiarch Build layotto wasm for multiple platform. -# wasm.image Build layotto wasm image for multiple platform. -# wasm.image.push Push layotto wasm image for multiple platform. -# check Run all go checks of code sources. -# check.lint Run go syntax and styling of go sources. -# check.unit Run go unit test. -# check.style Run go style test. -# style.coverage Run coverage analysis. -# style.deadlink Run deadlink check test. -# style.quickstart Run quickstart check test. -# integrate.wasm Run integration test with wasm. -# integrate.runtime Run integration test with runtime. -# format Format layotto go codes style with gofmt and goimports. -# clean Remove all files that are created by building. -# all Run format codes, check codes, build Layotto codes for host platform with one command -# help Show this help info. - -# ARGS: -# BINS The binaries to build. Default is all of cmd. -# This option is available when using: make build/build.multiarch -# Example: make build BINS="layotto_multiple_api layotto" -# IMAGES Backend images to make. Default is all of cmds. -# This option is available when using: make image/image.multiarch/push/push.multiarch -# Example: make image.multiarch IMAGES="layotto_multiple_api layotto" -# PLATFORMS The multiple platforms to build. Default is linux_amd64 and linux_arm64. -# This option is available when using: make build.multiarch/image.multiarch/push.multiarch -# Example: make image.multiarch IMAGES="layotto" PLATFORMS="linux_amd64 linux_arm64" -# Supported Platforms: linux_amd64 linux_arm64 darwin_amd64 darwin_arm64 - - -SHELL := /bin/bash - -# ============================================================================== -# ROOT Options: -# ============================================================================== - -ROOT_PACKAGE=mosn.io/layotto - -# ============================================================================== -# Includes: -# ============================================================================== - -include make/common.mk -include make/golang.mk -include make/image.mk -include make/wasm.mk -include make/ci.mk -include make/deploy.mk -include make/proto.mk - -# ============================================================================== -# Targets: -# ============================================================================== - -# ============================================================================== -## build: Build layotto for host platform. -# ============================================================================== -.PHONY: build -build: - @$(MAKE) go.build - -# ============================================================================== -## build.multiarch: Build layotto for multiple platforms. See option PLATFORMS. -# ============================================================================== -.PHONY: build.multiarch -build.multiarch: - @$(MAKE) go.build.multiarch - -# ============================================================================== -## image: Build docker images for host arch. -# ============================================================================== -.PHONY: image -image: - @$(MAKE) image.build - -# ============================================================================== -## image.multiarch: Build docker images for multiple platforms. See option PLATFORMS. -# ============================================================================== -.PHONY: image.multiarch -image.multiarch: - @$(MAKE) image.build.multiarch - -# ============================================================================== -## push: Push docker images to registry. -# ============================================================================== -.PHONY: push -push: - @$(MAKE) image.push - -# ============================================================================== -## push.multiarch: Push docker images for multiple platforms to registry. -# ============================================================================== -.PHONY: push.multiarch -push.multiarch: - @$(MAKE) image.push.multiarch - -# ============================================================================== -## app: Build app docker images for host arch. [`/docker/app` contains apps dockerfiles] -# ============================================================================== -.PHONY: app -app: - @$(MAKE) app.image - -# ============================================================================== -## app.multiarch: Build app docker images for multiple platforms. See option PLATFORMS. -# ============================================================================== -.PHONY: app.multiarch -app.multiarch: - @$(MAKE) app.image.multiarch - -# ============================================================================== -## wasm: Build layotto wasm for linux arm64 platform. -# ============================================================================== -.PHONY: wasm -wasm: - @$(MAKE) go.wasm - -# ============================================================================== -## wasm.multiarch: Build layotto wasm for multiple platform. -# ============================================================================== -.PHONY: wasm.multiarch -wasm.multiarch: - @$(MAKE) go.wasm.multiarch - -# ============================================================================== -## wasm.image: Build layotto wasm image for multiple platform. -# ============================================================================== -.PHONY: wasm.image -wasm.image: - @$(MAKE) go.wasm.image - -# ============================================================================== -## wasm.image.push: Push layotto wasm image for multiple platform. -# ============================================================================== -.PHONY: wasm.image.push -wasm.image.push: - @$(MAKE) go.wasm.image.push - -# ============================================================================== -## deploy: Deploy Layotto to Kubernetes -# ============================================================================== -.PHONY: deploy -deploy: - @$(MAKE) deploy.k8s - -# ============================================================================== -## deploy.standalone: Deploy Layotto to Kubernetes in Standalone Mode -# ============================================================================== -.PHONY: deploy.standalone -deploy.standalone: - @$(MAKE) deploy.k8s.standalone - -# ============================================================================== -## undeploy: Remove Layotto in Kubernetes -# ============================================================================== -.PHONY: undeploy -undeploy: - @$(MAKE) undeploy.k8s - -# ============================================================================== -## undeploy.standalone: Remove Layotto in Kubernetes in Standalone Mode -# ============================================================================== -.PHONY: undeploy.standalone -undeploy.standalone: - @$(MAKE) undeploy.k8s.standalone - -# ============================================================================== -## check: Run all go checks of code sources. -# ============================================================================== -.PHONY: check -check: check.style check.unit check.lint - -# ============================================================================== -## check.lint: Run go syntax and styling of go sources. -# ============================================================================== -.PHONY: check.lint -check.lint: - @$(MAKE) go.lint - -# ============================================================================== -## check.unit: Run go unit test. -# ============================================================================== -.PHONY: check.unit -check.unit: - @$(MAKE) go.test - -# ============================================================================== -## check.style: Run go style test. -# ============================================================================== -.PHONY: check.style -check.style: - @$(MAKE) go.style - -# ============================================================================== -## style.coverage: Run coverage analysis. -# ============================================================================== -.PHONY: style.coverage -style.coverage: - @$(MAKE) checker.coverage - -# ============================================================================== -## style.deadlink: Run deadlink check test. -# ============================================================================== -.PHONY: style.deadlink -style.deadlink: - @$(MAKE) checker.deadlink - -# ============================================================================== -## style.quickstart: Run quickstart check test. -# ============================================================================== -.PHONY: style.quickstart -style.quickstart: - @$(MAKE) checker.quickstart - -# ============================================================================== -## license: Add license headers for code files. -# ============================================================================== -.PHONY: license -license: - @$(MAKE) checker.license.fix - -# ============================================================================== -## integrate.wasm: Run integration test with wasm. -# ============================================================================== -.PHONY: integrate.wasm -integrate.wasm: - @$(MAKE) integration.wasm - -# ============================================================================== -## integrate.runtime: Run integration test with runtime. -# ============================================================================== -.PHONY: integrate.runtime -integrate.runtime: - @$(MAKE) integration.runtime - -# ============================================================================== -## format: Format layotto go codes style with gofmt and goimports. -# ============================================================================== -.PHONY: format -format: go.format - -# ============================================================================== -## clean: Remove all files that are created by building. -# ============================================================================== -.PHONY: clean -clean: - @$(MAKE) go.clean - -# ============================================================================== -## proto.doc: Generate documentation according to the proto files. -# ============================================================================== -.PHONY: proto.doc -proto.doc: - @$(MAKE) proto.gen.doc - -# ============================================================================== -## proto: Generate code and documentation based on the proto files. -# ============================================================================== -.PHONY: proto -proto: - @$(MAKE) proto.gen.all - -# ============================================================================== -## proto.init: Install protoc-gen-go and protoc-gen-go-grpc -# ============================================================================== -.PHONY: proto.init -proto.init: - @$(MAKE) proto.gen.init - -# ============================================================================== -## proto.code: Generate pb.go code according to the proto files. -# ============================================================================== -.PHONY: proto.code -proto.code: - @$(MAKE) proto.gen.code - -# ============================================================================== -## all: Run format codes, check codes, build Layotto codes for host platform with one command -# ============================================================================== -.PHONY: all -all: clean format check style.quickstart clean - -# ============================================================================== -# Usage -# ============================================================================== - -define USAGE_OPTIONS - -ARGS: - BINS The binaries to build. Default is all of cmd. - This option is available when using: make build/build.multiarch - Example: make build BINS="layotto_multiple_api layotto" - IMAGES Backend images to make. Default is all of cmds. - This option is available when using: make image/image.multiarch/push/push.multiarch - Example: make image.multiarch IMAGES="layotto_multiple_api layotto" - PLATFORMS The multiple platforms to build. Default is linux_amd64 and linux_arm64. - This option is available when using: make build.multiarch/image.multiarch/push.multiarch - Example: make image.multiarch IMAGES="layotto" PLATFORMS="linux_amd64 linux_arm64" - Supported Platforms: linux_amd64 linux_arm64 darwin_amd64 darwin_arm64 - NAMESPACE The namepace to deploy. Default is `default`. - This option is available when using: make deploy/deploy.standalone/undeploy/undeploy.standalone - Example: make deploy NAMESPACE="layotto" -endef -export USAGE_OPTIONS - -# ============================================================================== -# Help -# ============================================================================== - -## help: Show this help info. -.PHONY: help -help: Makefile - @echo -e "Layotto commands 👀: \n\nA fast and efficient cloud native application runtime 🚀." - @echo -e "Commands below are used in Development 💻 and GitHub workflow 🌊.\n" - @echo -e "Usage: make ...\n\nCOMMANDS:" - @sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /' - @echo "$$USAGE_OPTIONS" \ No newline at end of file +# All make targets should be implemented in make/*.mk +# ==================================================================================================== +# Supported Targets: (Run `make help` to see more information) +# ==================================================================================================== + +# This file is a wrapper around `make` so that we can force on the +# --warn-undefined-variables flag. Sure, you can set +# `MAKEFLAGS += --warn-undefined-variables` from inside of a Makefile, +# but then it won't turn on until the second phase (recipe execution), +# and won't actually be on during the initial phase (parsing). +# See: https://www.gnu.org/software/make/manual/make.html#Reading-Makefiles + +# Have everything-else ("%") depend on _run (which uses +# $(MAKECMDGOALS) to decide what to run), rather than having +# everything else run $(MAKE) directly, since that'd end up running +# multiple sub-Makes if you give multiple targets on the CLI. +_run: + @$(MAKE) --warn-undefined-variables -f make/common.mk $(MAKECMDGOALS) +.PHONY: _run +$(if $(MAKECMDGOALS),$(MAKECMDGOALS): %: _run) \ No newline at end of file diff --git a/docs/en/api_reference/how_to_generate_api_doc.md b/docs/en/api_reference/how_to_generate_api_doc.md index 0292f05d52..5648ed3d30 100644 --- a/docs/en/api_reference/how_to_generate_api_doc.md +++ b/docs/en/api_reference/how_to_generate_api_doc.md @@ -102,7 +102,7 @@ The steps above generate everything, but what if I only want to generate `.pb.go #### **Make cmmand(recommended)** ```bash -make proto.code +make proto-code ``` This command uses docker to run protoc and generate `.pb.go` code files. @@ -127,14 +127,14 @@ We can use [protoc-gen-doc](https://github.com/pseudomuto/protoc-gen-doc) and do #### **Make command(recommended)** ```bash -make proto.doc +make proto-doc ``` This command uses docker to run protoc-gen-doc and generate docs. #### **Use docker to run protoc-gen-doc** -`make proto.doc` invokes the script `etc/script/generate-doc.sh`, which uses docker to run protoc-gen-doc. +`make proto-doc` invokes the script `etc/script/generate-doc.sh`, which uses docker to run protoc-gen-doc. You can check `etc/script/generate-doc.sh` for more details. - \ No newline at end of file + diff --git a/docs/en/development/commands.md b/docs/en/development/commands.md index 861f150e80..cd686a3ed2 100644 --- a/docs/en/development/commands.md +++ b/docs/en/development/commands.md @@ -18,50 +18,91 @@ Layotto provides powerful commands, which makes contribution and local developme See below commands to know more details or excute `make help`: ``` -Layotto commands 👀: - -A fast and efficient cloud native application runtime 🚀. -Commands below are used in Development 💻 and GitHub workflow 🌊. - -Usage: make ... - -COMMANDS: - build Build layotto for host platform. - build.multiarch Build layotto for multiple platforms. See option PLATFORMS. - image Build docker images for host arch. - image.multiarch Build docker images for multiple platforms. See option PLATFORMS. - push Push docker images to registry. - push.multiarch Push docker images for multiple platforms to registry. - app Build app docker images for host arch. [`/docker/app` contains apps dockerfiles] - app.multiarch Build app docker images for multiple platforms. See option PLATFORMS. - wasm Build layotto wasm for linux arm64 platform. - wasm.multiarch Build layotto wasm for multiple platform. - wasm.image Build layotto wasm image for multiple platform. - wasm.image.push Push layotto wasm image for multiple platform. - check Run all go checks of code sources. - check.lint Run go syntax and styling of go sources. - check.unit Run go unit test. - check.style Run go style test. - style.coverage Run coverage analysis. - style.deadlink Run deadlink check test. - style.quickstart Run quickstart check test. - license Add license headers for code files. - integrate.wasm Run integration test with wasm. - integrate.runtime Run integration test with runtime. - format Format layotto go codes style with gofmt and goimports. - clean Remove all files that are created by building. - all Run format codes, check codes, build Layotto codes for host platform with one command - help Show this help info. - -ARGS: +Layotto is an open source project for a fast and efficient cloud native application runtime. + +Usage: + make