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 @@
apply the dynamic configuration
Apply the dynamic configuration. +The DynamicConfiguration here should be full configuration, not incremental configuration
CSVInput
+ + +Field | Type | Label | Description |
allow_quoted_record_delimiter | +bool | ++ | Specifies that CSV field values may contain quoted record delimiters and such +records should be allowed. Default value is FALSE. Setting this value to TRUE +may lower performance. |
+
comments | +string | ++ | A single character used to indicate that a row should be ignored when the +character is present at the start of that row. You can specify any character to +indicate a comment line. |
+
field_delimiter | +string | ++ | A single character used to separate individual fields in a record. You can +specify an arbitrary delimiter. |
+
file_header_info | +string | ++ | Describes the first line of input. Valid values are: + +* NONE: First line is not +a header. + +* IGNORE: First line is a header, but you can't use the header values +to indicate the column in an expression. You can use column position (such as +_1, _2, …) to indicate the column (SELECT s._1 FROM OBJECT s). + +* Use: First +line is a header, and you can use the header value to identify a column in an +expression (SELECT "name" FROM OBJECT). |
+
quote_character | +string | ++ | A single character used for escaping when the field delimiter is part of the +value. For example, if the value is a, b, Amazon S3 wraps this field value in +quotation marks, as follows: " a , b ". Type: String Default: " Ancestors: CSV |
+
quote_escape_character | +string | ++ | A single character used for escaping the quotation mark character inside an +already escaped value. For example, the value """ a , b """ is parsed as " a , b +". |
+
record_delimiter | +string | ++ | A single character used to separate individual records in the input. Instead of +the default value, you can specify an arbitrary delimiter. |
+
CSVOutput
+ + +Field | Type | Label | Description |
field_delimiter | +string | ++ | The value used to separate individual fields in a record. You can specify an +arbitrary delimiter. |
+
quote_character | +string | ++ | A single character used for escaping when the field delimiter is part of the +value. For example, if the value is a, b, Amazon S3 wraps this field value in +quotation marks, as follows: " a , b ". |
+
quote_escape_character | +string | ++ | The single character used for escaping the quote character inside an already +escaped value. |
+
quote_fields | +string | ++ | Indicates whether to use quotation marks around output fields. + +* ALWAYS: Always +use quotation marks for output fields. + +* ASNEEDED: Use quotation marks for +output fields when needed. |
+
record_delimiter | +string | ++ | A single character used to separate individual records in the output. Instead of +the default value, you can specify an arbitrary delimiter. |
+
CompleteMultipartUploadInput
@@ -2972,6 +3154,31 @@GlacierJobParameters
+ + +Field | Type | Label | Description |
tier | +string | ++ | Retrieval tier at which the restore will be processed. +This member is required. |
+
HeadObjectInput
@@ -3197,6 +3404,45 @@InputSerialization
+ + +Field | Type | Label | Description |
csv | +CSVInput | ++ | Describes the serialization of a CSV-encoded object. |
+
compression_type | +string | ++ | Specifies object's compression format. Valid values: NONE, GZIP, BZIP2. Default +Value: NONE. |
+
json | +string | ++ | Specifies JSON as object's input serialization format. |
+
IsObjectExistInput
@@ -4250,6 +4496,70 @@OutPutLocation
+ + +Field | Type | Label | Description |
bucket_name | +string | ++ | The name of the bucket where the restore results will be placed. +This member is required. |
+
prefix | +string | ++ | The prefix that is prepended to the restore results for this request. +This member is required. |
+
OutputSerialization
+ + +Field | Type | Label | Description |
csv | +CSVOutput | ++ | Describes the serialization of CSV-encoded Select results. |
+
json | +string | ++ | Specifies JSON as request's output serialization format. |
+
Owner
@@ -4524,6 +4834,13 @@The tag-set for the object. The tag-set must be encoded as URL Query parameters.
Storage class options.
The information of restoring request.
RestoreRequest
+ + +Field | Type | Label | Description |
days | +int32 | ++ | Lifetime of the active copy in days. |
+
description | +string | ++ | The optional description for the job. |
+
glacier_job_parameters | +GlacierJobParameters | ++ | S3 Glacier related parameters pertaining to this job. |
+
output_location | +OutputLocation | ++ | Describes the location where the restore job's output is stored. |
+
select_parameters | +SelectParameters | ++ | Describes the parameters for Select job types. |
+
tier | +string | ++ | Retrieval tier at which the restore will be processed. |
+
type | +string | ++ | Type of restore request. |
+
SelectParameters
+ + +Field | Type | Label | Description |
expression | +string | ++ | The expression that is used to query the object. +This member is required. |
+
expression_type | +string | ++ | The type of the provided expression (for example, SQL). +This member is required. |
+
input_serialization | +InputSerialization | ++ | Describes the serialization format of the object. +This member is required. |
+
output_serialization | +OutputSerialization | ++ | Describes how the results of the Select job are serialized. +This member is required. |
+
SignURLInput
diff --git a/docs/en/api_reference/README.md b/docs/en/api_reference/README.md index 7d98ef9fcc..dfc9097e5c 100644 --- a/docs/en/api_reference/README.md +++ b/docs/en/api_reference/README.md @@ -11,4 +11,8 @@ 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/zh/api_reference/README.md b/docs/zh/api_reference/README.md index c5b88649d3..e0a717e23d 100644 --- a/docs/zh/api_reference/README.md +++ b/docs/zh/api_reference/README.md @@ -11,4 +11,8 @@ 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/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/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..4070d4c1e1 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,28 @@ package runtime import ( - s3ext "mosn.io/layotto/pkg/grpc/extension/s3" + email "mosn.io/layotto/components/email" + phone "mosn.io/layotto/components/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 WithExtensionGrpcAPI() Option { - return WithGrpcAPI( - s3ext.NewS3Server, - ) +func WithPhoneCallServiceFactory(phone ...*phone.Factory) Option { + return func(o *runtimeOptions) { + o.services.phone = append(o.services.phone, phone...) + } } diff --git a/sdk/go-sdk/client/client.go b/sdk/go-sdk/client/client.go index c7990f8592..b650053671 100644 --- a/sdk/go-sdk/client/client.go +++ b/sdk/go-sdk/client/client.go @@ -23,8 +23,6 @@ import ( "os" "sync" - "mosn.io/layotto/spec/proto/extension/v1/s3" - "github.com/pkg/errors" "google.golang.org/grpc" 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/s3/oss.pb.go b/spec/proto/extension/v1/s3/oss.pb.go index b37c66a7ee..c73c2abeb7 100644 --- a/spec/proto/extension/v1/s3/oss.pb.go +++ b/spec/proto/extension/v1/s3/oss.pb.go @@ -8541,7 +8541,10 @@ var file_oss_proto_rawDesc = []byte{ 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, 0x79, 0x6f, 0x74, + 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, diff --git a/spec/proto/runtime/v1/lifecycle.pb.go b/spec/proto/runtime/v1/lifecycle.pb.go index c27533794e..86dfb9e917 100644 --- a/spec/proto/runtime/v1/lifecycle.pb.go +++ b/spec/proto/runtime/v1/lifecycle.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.0 +// protoc-gen-go v1.28.1 // protoc v3.17.3 // source: lifecycle.proto