/
main.go
524 lines (480 loc) · 19.5 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
/*
* 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 main
import (
"encoding/json"
"os"
"strconv"
"time"
"mosn.io/layotto/pkg/grpc/lifecycle"
"mosn.io/layotto/components/oss"
aws_oss "mosn.io/layotto/components/oss/aws"
aliyun_oss "mosn.io/layotto/components/oss/aliyun"
ceph_oss "mosn.io/layotto/components/oss/ceph"
"mosn.io/mosn/pkg/istio"
aliyun_file "mosn.io/layotto/components/file/aliyun"
"github.com/dapr/components-contrib/secretstores"
"github.com/dapr/components-contrib/secretstores/aws/parameterstore"
"github.com/dapr/components-contrib/secretstores/aws/secretmanager"
"github.com/dapr/components-contrib/secretstores/azure/keyvault"
gcp_secretmanager "github.com/dapr/components-contrib/secretstores/gcp/secretmanager"
"github.com/dapr/components-contrib/secretstores/hashicorp/vault"
sercetstores_kubernetes "github.com/dapr/components-contrib/secretstores/kubernetes"
secretstore_env "github.com/dapr/components-contrib/secretstores/local/env"
secretstore_file "github.com/dapr/components-contrib/secretstores/local/file"
"mosn.io/layotto/components/file/aws"
"mosn.io/layotto/components/file/minio"
"mosn.io/layotto/components/file/qiniu"
"mosn.io/layotto/components/file/tencentcloud"
"mosn.io/layotto/pkg/grpc/default_api"
secretstores_loader "mosn.io/layotto/pkg/runtime/secretstores"
"mosn.io/layotto/components/file/local"
mock_state "mosn.io/layotto/pkg/mock/components/state"
dbindings "github.com/dapr/components-contrib/bindings"
"github.com/dapr/components-contrib/bindings/http"
"mosn.io/pkg/log"
"mosn.io/layotto/components/configstores/etcdv3"
"mosn.io/layotto/components/file"
"mosn.io/layotto/components/sequencer"
"mosn.io/layotto/pkg/runtime/bindings"
runtime_sequencer "mosn.io/layotto/pkg/runtime/sequencer"
// Hello
"mosn.io/layotto/components/hello"
"mosn.io/layotto/components/hello/helloworld"
// Configuration
"mosn.io/layotto/components/configstores"
"mosn.io/layotto/components/configstores/apollo"
// Pub/Sub
dapr_comp_pubsub "github.com/dapr/components-contrib/pubsub"
pubsub_snssqs "github.com/dapr/components-contrib/pubsub/aws/snssqs"
pubsub_eventhubs "github.com/dapr/components-contrib/pubsub/azure/eventhubs"
pubsub_gcp "github.com/dapr/components-contrib/pubsub/gcp/pubsub"
pubsub_hazelcast "github.com/dapr/components-contrib/pubsub/hazelcast"
pubsub_inmemory "github.com/dapr/components-contrib/pubsub/in-memory"
pubsub_kafka "github.com/dapr/components-contrib/pubsub/kafka"
pubsub_mqtt "github.com/dapr/components-contrib/pubsub/mqtt"
"github.com/dapr/components-contrib/pubsub/natsstreaming"
pubsub_pulsar "github.com/dapr/components-contrib/pubsub/pulsar"
"github.com/dapr/components-contrib/pubsub/rabbitmq"
pubsub_redis "github.com/dapr/components-contrib/pubsub/redis"
"github.com/dapr/kit/logger"
"mosn.io/layotto/pkg/runtime/pubsub"
servicebus "mosn.io/layotto/components/delay_queue/azure/servicebus"
// RPC
"mosn.io/layotto/components/rpc"
mosninvoker "mosn.io/layotto/components/rpc/invoker/mosn"
// State Stores
"github.com/dapr/components-contrib/state"
"github.com/dapr/components-contrib/state/aerospike"
state_dynamodb "github.com/dapr/components-contrib/state/aws/dynamodb"
state_azure_blobstorage "github.com/dapr/components-contrib/state/azure/blobstorage"
state_cosmosdb "github.com/dapr/components-contrib/state/azure/cosmosdb"
state_azure_tablestorage "github.com/dapr/components-contrib/state/azure/tablestorage"
"github.com/dapr/components-contrib/state/cassandra"
"github.com/dapr/components-contrib/state/cloudstate"
"github.com/dapr/components-contrib/state/couchbase"
"github.com/dapr/components-contrib/state/gcp/firestore"
"github.com/dapr/components-contrib/state/hashicorp/consul"
"github.com/dapr/components-contrib/state/hazelcast"
"github.com/dapr/components-contrib/state/memcached"
"github.com/dapr/components-contrib/state/mongodb"
state_mysql "github.com/dapr/components-contrib/state/mysql"
"github.com/dapr/components-contrib/state/postgresql"
state_redis "github.com/dapr/components-contrib/state/redis"
"github.com/dapr/components-contrib/state/rethinkdb"
"github.com/dapr/components-contrib/state/sqlserver"
"github.com/dapr/components-contrib/state/zookeeper"
runtime_state "mosn.io/layotto/pkg/runtime/state"
// Lock
"mosn.io/layotto/components/lock"
lock_consul "mosn.io/layotto/components/lock/consul"
lock_etcd "mosn.io/layotto/components/lock/etcd"
lock_inmemory "mosn.io/layotto/components/lock/in-memory"
lock_mongo "mosn.io/layotto/components/lock/mongo"
lock_redis "mosn.io/layotto/components/lock/redis"
lock_zookeeper "mosn.io/layotto/components/lock/zookeeper"
runtime_lock "mosn.io/layotto/pkg/runtime/lock"
// Sequencer
sequencer_etcd "mosn.io/layotto/components/sequencer/etcd"
sequencer_inmemory "mosn.io/layotto/components/sequencer/in-memory"
sequencer_mongo "mosn.io/layotto/components/sequencer/mongo"
sequencer_mysql "mosn.io/layotto/components/sequencer/mysql"
sequencer_redis "mosn.io/layotto/components/sequencer/redis"
sequencer_snowflake "mosn.io/layotto/components/sequencer/snowflake"
sequencer_zookeeper "mosn.io/layotto/components/sequencer/zookeeper"
// Actuator
_ "mosn.io/layotto/pkg/actuator"
"mosn.io/layotto/pkg/actuator/health"
actuatorInfo "mosn.io/layotto/pkg/actuator/info"
_ "mosn.io/layotto/pkg/filter/stream/actuator/http"
"mosn.io/layotto/pkg/integrate/actuator"
"github.com/urfave/cli"
"google.golang.org/grpc"
_ "mosn.io/mosn/pkg/filter/network/grpc"
mgrpc "mosn.io/mosn/pkg/filter/network/grpc"
_ "mosn.io/mosn/pkg/filter/network/proxy"
_ "mosn.io/mosn/pkg/filter/stream/flowcontrol"
_ "mosn.io/mosn/pkg/filter/stream/grpcmetric"
_ "mosn.io/mosn/pkg/metrics/sink"
_ "mosn.io/mosn/pkg/metrics/sink/prometheus"
_ "mosn.io/mosn/pkg/network"
_ "mosn.io/mosn/pkg/stream/http"
_ "mosn.io/mosn/pkg/wasm/runtime/wasmer"
_ "mosn.io/pkg/buffer"
_ "mosn.io/layotto/pkg/filter/network/tcpcopy"
_ "mosn.io/layotto/pkg/filter/stream/wasm/http"
l8_grpc "mosn.io/layotto/pkg/grpc"
"mosn.io/layotto/pkg/runtime"
_ "mosn.io/layotto/pkg/wasm"
_ "mosn.io/layotto/pkg/wasm/install"
_ "mosn.io/layotto/pkg/wasm/uninstall"
_ "mosn.io/layotto/pkg/wasm/update"
_ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/router/v3"
_ "mosn.io/mosn/istio/istio1106"
_ "mosn.io/mosn/istio/istio1106/filter/stream/jwtauthn"
_ "mosn.io/mosn/istio/istio1106/filter/stream/mixer"
_ "mosn.io/mosn/istio/istio1106/filter/stream/stats"
_ "mosn.io/mosn/istio/istio1106/sds"
_ "mosn.io/mosn/istio/istio1106/xds"
_ "mosn.io/mosn/pkg/filter/listener/originaldst"
_ "mosn.io/mosn/pkg/filter/network/connectionmanager"
_ "mosn.io/mosn/pkg/filter/network/streamproxy"
_ "mosn.io/mosn/pkg/filter/network/tunnel"
_ "mosn.io/mosn/pkg/filter/stream/dsl"
_ "mosn.io/mosn/pkg/filter/stream/dubbo"
_ "mosn.io/mosn/pkg/filter/stream/faultinject"
_ "mosn.io/mosn/pkg/filter/stream/faulttolerance"
_ "mosn.io/mosn/pkg/filter/stream/gzip"
_ "mosn.io/mosn/pkg/filter/stream/headertometadata"
_ "mosn.io/mosn/pkg/filter/stream/ipaccess"
_ "mosn.io/mosn/pkg/filter/stream/mirror"
_ "mosn.io/mosn/pkg/filter/stream/payloadlimit"
_ "mosn.io/mosn/pkg/filter/stream/proxywasm"
_ "mosn.io/mosn/pkg/filter/stream/seata"
_ "mosn.io/mosn/pkg/filter/stream/transcoder/http2bolt"
_ "mosn.io/mosn/pkg/filter/stream/transcoder/httpconv"
_ "mosn.io/mosn/pkg/protocol"
_ "mosn.io/mosn/pkg/protocol/xprotocol"
_ "mosn.io/mosn/pkg/router"
_ "mosn.io/mosn/pkg/server/keeper"
_ "mosn.io/mosn/pkg/stream/http2"
_ "mosn.io/mosn/pkg/stream/xprotocol"
_ "mosn.io/mosn/pkg/trace/jaeger"
_ "mosn.io/mosn/pkg/trace/skywalking"
_ "mosn.io/mosn/pkg/trace/skywalking/http"
_ "mosn.io/mosn/pkg/trace/sofa/http"
_ "mosn.io/mosn/pkg/trace/sofa/xprotocol"
_ "mosn.io/mosn/pkg/trace/sofa/xprotocol/bolt"
_ "mosn.io/mosn/pkg/upstream/healthcheck"
_ "mosn.io/mosn/pkg/upstream/servicediscovery/dubbod"
_ "mosn.io/layotto/diagnostics/exporter_iml"
)
// loggerForDaprComp is constructed for reusing dapr's components.
var loggerForDaprComp = logger.NewLogger("reuse.dapr.component")
// GitVersion mosn version is specified by latest tag
var GitVersion = ""
var IstioVersion = "1.10.6"
func init() {
mgrpc.RegisterServerHandler("runtime", NewRuntimeGrpcServer)
// Register default actuator implementations
actuatorInfo.AddInfoContributor("app", actuator.GetAppContributor())
health.AddReadinessIndicator("runtime_startup", actuator.GetRuntimeReadinessIndicator())
health.AddLivenessIndicator("runtime_startup", actuator.GetRuntimeLivenessIndicator())
}
func NewRuntimeGrpcServer(data json.RawMessage, opts ...grpc.ServerOption) (mgrpc.RegisteredServer, error) {
var err error
defer func() {
if err != nil {
// fail fast if error occurs during startup.
// The reason we panic in a new goroutine is to prevent mosn from recovering.
go func() {
log.DefaultLogger.Errorf("An error occurred during startup : %v", err)
panic(err)
}()
}
}()
// 1. parse config
cfg, err := runtime.ParseRuntimeConfig(data)
if err != nil {
return nil, err
}
// 2. new instance
rt := runtime.NewMosnRuntime(cfg)
rt.AppendInitRuntimeStage(runtime.DefaultInitRuntimeStage)
// 3. run
server, err := rt.Run(
runtime.WithGrpcOptions(opts...),
// wrap the grpc server with actuator
runtime.WithNewServer(func(apis []l8_grpc.GrpcAPI, opts ...grpc.ServerOption) (mgrpc.RegisteredServer, error) {
server, err := l8_grpc.NewDefaultServer(apis, opts...)
if err != nil {
return nil, err
}
return actuator.NewGrpcServerWithActuator(server)
}),
// register your gRPC API here
runtime.WithGrpcAPI(
default_api.NewGrpcAPI,
lifecycle.NewLifecycleAPI,
),
runtime.WithExtensionGrpcAPI(),
// Hello
runtime.WithHelloFactory(
hello.NewHelloFactory("helloworld", helloworld.NewHelloWorld),
),
// Configuration
runtime.WithConfigStoresFactory(
configstores.NewStoreFactory("apollo", apollo.NewStore),
configstores.NewStoreFactory("etcd", etcdv3.NewStore),
),
// RPC
runtime.WithRpcFactory(
rpc.NewRpcFactory("mosn", mosninvoker.NewMosnInvoker),
),
// File
runtime.WithFileFactory(
file.NewFileFactory("aliyun.oss", aliyun_file.NewAliyunFile),
file.NewFileFactory("minio", minio.NewMinioOss),
file.NewFileFactory("aws.s3", aws.NewAwsFile),
file.NewFileFactory("tencent.oss", tencentcloud.NewTencentCloudOSS),
file.NewFileFactory("local", local.NewLocalStore),
file.NewFileFactory("qiniu.oss", qiniu.NewQiniuOSS),
),
runtime.WithOssFactory(
oss.NewFactory("aws.oss", aws_oss.NewAwsOss),
oss.NewFactory("aliyun.oss", aliyun_oss.NewAliyunOss),
oss.NewFactory("ceph", ceph_oss.NewCephOss),
),
// PubSub
runtime.WithPubSubFactory(
pubsub.NewFactory("redis", func() dapr_comp_pubsub.PubSub {
return pubsub_redis.NewRedisStreams(loggerForDaprComp)
}),
pubsub.NewFactory("natsstreaming", func() dapr_comp_pubsub.PubSub {
return natsstreaming.NewNATSStreamingPubSub(loggerForDaprComp)
}),
pubsub.NewFactory("azure.eventhubs", func() dapr_comp_pubsub.PubSub {
return pubsub_eventhubs.NewAzureEventHubs(loggerForDaprComp)
}),
pubsub.NewFactory("azure.servicebus", func() dapr_comp_pubsub.PubSub {
return servicebus.NewAzureServiceBus(loggerForDaprComp)
}),
pubsub.NewFactory("rabbitmq", func() dapr_comp_pubsub.PubSub {
return rabbitmq.NewRabbitMQ(loggerForDaprComp)
}),
pubsub.NewFactory("hazelcast", func() dapr_comp_pubsub.PubSub {
return pubsub_hazelcast.NewHazelcastPubSub(loggerForDaprComp)
}),
pubsub.NewFactory("gcp.pubsub", func() dapr_comp_pubsub.PubSub {
return pubsub_gcp.NewGCPPubSub(loggerForDaprComp)
}),
pubsub.NewFactory("kafka", func() dapr_comp_pubsub.PubSub {
return pubsub_kafka.NewKafka(loggerForDaprComp)
}),
pubsub.NewFactory("snssqs", func() dapr_comp_pubsub.PubSub {
return pubsub_snssqs.NewSnsSqs(loggerForDaprComp)
}),
pubsub.NewFactory("mqtt", func() dapr_comp_pubsub.PubSub {
return pubsub_mqtt.NewMQTTPubSub(loggerForDaprComp)
}),
pubsub.NewFactory("pulsar", func() dapr_comp_pubsub.PubSub {
return pubsub_pulsar.NewPulsar(loggerForDaprComp)
}),
pubsub.NewFactory("in-memory", func() dapr_comp_pubsub.PubSub {
return pubsub_inmemory.New(loggerForDaprComp)
}),
),
// State
runtime.WithStateFactory(
runtime_state.NewFactory("in-memory", func() state.Store {
return mock_state.New(loggerForDaprComp)
}),
runtime_state.NewFactory("redis", func() state.Store {
return state_redis.NewRedisStateStore(loggerForDaprComp)
}),
runtime_state.NewFactory("consul", func() state.Store {
return consul.NewConsulStateStore(loggerForDaprComp)
}),
runtime_state.NewFactory("azure.blobstorage", func() state.Store {
return state_azure_blobstorage.NewAzureBlobStorageStore(loggerForDaprComp)
}),
runtime_state.NewFactory("azure.cosmosdb", func() state.Store {
return state_cosmosdb.NewCosmosDBStateStore(loggerForDaprComp)
}),
runtime_state.NewFactory("azure.tablestorage", func() state.Store {
return state_azure_tablestorage.NewAzureTablesStateStore(loggerForDaprComp)
}),
runtime_state.NewFactory("cassandra", func() state.Store {
return cassandra.NewCassandraStateStore(loggerForDaprComp)
}),
runtime_state.NewFactory("memcached", func() state.Store {
return memcached.NewMemCacheStateStore(loggerForDaprComp)
}),
runtime_state.NewFactory("mongodb", func() state.Store {
return mongodb.NewMongoDB(loggerForDaprComp)
}),
runtime_state.NewFactory("zookeeper", func() state.Store {
return zookeeper.NewZookeeperStateStore(loggerForDaprComp)
}),
runtime_state.NewFactory("gcp.firestore", func() state.Store {
return firestore.NewFirestoreStateStore(loggerForDaprComp)
}),
runtime_state.NewFactory("postgresql", func() state.Store {
return postgresql.NewPostgreSQLStateStore(loggerForDaprComp)
}),
runtime_state.NewFactory("sqlserver", func() state.Store {
return sqlserver.NewSQLServerStateStore(loggerForDaprComp)
}),
runtime_state.NewFactory("hazelcast", func() state.Store {
return hazelcast.NewHazelcastStore(loggerForDaprComp)
}),
runtime_state.NewFactory("cloudstate.crdt", func() state.Store {
return cloudstate.NewCRDT(loggerForDaprComp)
}),
runtime_state.NewFactory("couchbase", func() state.Store {
return couchbase.NewCouchbaseStateStore(loggerForDaprComp)
}),
runtime_state.NewFactory("aerospike", func() state.Store {
return aerospike.NewAerospikeStateStore(loggerForDaprComp)
}),
runtime_state.NewFactory("rethinkdb", func() state.Store {
return rethinkdb.NewRethinkDBStateStore(loggerForDaprComp)
}),
runtime_state.NewFactory("aws.dynamodb", state_dynamodb.NewDynamoDBStateStore),
runtime_state.NewFactory("mysql", func() state.Store {
return state_mysql.NewMySQLStateStore(loggerForDaprComp)
}),
),
// Lock
runtime.WithLockFactory(
runtime_lock.NewFactory("redis_cluster", func() lock.LockStore {
return lock_redis.NewClusterRedisLock(log.DefaultLogger)
}),
runtime_lock.NewFactory("redis", func() lock.LockStore {
return lock_redis.NewStandaloneRedisLock(log.DefaultLogger)
}),
runtime_lock.NewFactory("zookeeper", func() lock.LockStore {
return lock_zookeeper.NewZookeeperLock(log.DefaultLogger)
}),
runtime_lock.NewFactory("etcd", func() lock.LockStore {
return lock_etcd.NewEtcdLock(log.DefaultLogger)
}),
runtime_lock.NewFactory("consul", func() lock.LockStore {
return lock_consul.NewConsulLock(log.DefaultLogger)
}),
runtime_lock.NewFactory("mongo", func() lock.LockStore {
return lock_mongo.NewMongoLock(log.DefaultLogger)
}),
runtime_lock.NewFactory("in-memory", func() lock.LockStore {
return lock_inmemory.NewInMemoryLock()
}),
),
// bindings
runtime.WithOutputBindings(
bindings.NewOutputBindingFactory("http", func() dbindings.OutputBinding {
return http.NewHTTP(loggerForDaprComp)
}),
),
// Sequencer
runtime.WithSequencerFactory(
runtime_sequencer.NewFactory("etcd", func() sequencer.Store {
return sequencer_etcd.NewEtcdSequencer(log.DefaultLogger)
}),
runtime_sequencer.NewFactory("redis", func() sequencer.Store {
return sequencer_redis.NewStandaloneRedisSequencer(log.DefaultLogger)
}),
runtime_sequencer.NewFactory("zookeeper", func() sequencer.Store {
return sequencer_zookeeper.NewZookeeperSequencer(log.DefaultLogger)
}),
runtime_sequencer.NewFactory("mongo", func() sequencer.Store {
return sequencer_mongo.NewMongoSequencer(log.DefaultLogger)
}),
runtime_sequencer.NewFactory("in-memory", func() sequencer.Store {
return sequencer_inmemory.NewInMemorySequencer()
}),
runtime_sequencer.NewFactory("mysql", func() sequencer.Store {
return sequencer_mysql.NewMySQLSequencer(log.DefaultLogger)
}),
runtime_sequencer.NewFactory("snowflake", func() sequencer.Store {
return sequencer_snowflake.NewSnowFlakeSequencer(log.DefaultLogger)
}),
),
// secretstores
runtime.WithSecretStoresFactory(
secretstores_loader.NewFactory("kubernetes", func() secretstores.SecretStore {
return sercetstores_kubernetes.NewKubernetesSecretStore(loggerForDaprComp)
}),
secretstores_loader.NewFactory("azure.keyvault", func() secretstores.SecretStore {
return keyvault.NewAzureKeyvaultSecretStore(loggerForDaprComp)
}),
secretstores_loader.NewFactory("hashicorp.vault", func() secretstores.SecretStore {
return vault.NewHashiCorpVaultSecretStore(loggerForDaprComp)
}),
secretstores_loader.NewFactory("aws.secretmanager", func() secretstores.SecretStore {
return secretmanager.NewSecretManager(loggerForDaprComp)
}),
secretstores_loader.NewFactory("aws.parameterstore", func() secretstores.SecretStore {
return parameterstore.NewParameterStore(loggerForDaprComp)
}),
secretstores_loader.NewFactory("gcp.secretmanager", func() secretstores.SecretStore {
return gcp_secretmanager.NewSecreteManager(loggerForDaprComp)
}),
secretstores_loader.NewFactory("local.file", func() secretstores.SecretStore {
return secretstore_file.NewLocalSecretStore(loggerForDaprComp)
}),
secretstores_loader.NewFactory("local.env", func() secretstores.SecretStore {
return secretstore_env.NewEnvSecretStore(loggerForDaprComp)
}),
))
return server, err
}
func main() {
app := newRuntimeApp(&cmdStart)
registerAppInfo(app)
_ = app.Run(os.Args)
}
func registerAppInfo(app *cli.App) {
appInfo := actuator.NewAppInfo()
appInfo.Name = app.Name
appInfo.Version = app.Version
appInfo.Compiled = app.Compiled
actuator.SetAppInfoSingleton(appInfo)
// set istio version
istio.IstioVersion = IstioVersion
}
func newRuntimeApp(startCmd *cli.Command) *cli.App {
app := cli.NewApp()
app.Name = "Layotto"
app.Version = GitVersion
app.Compiled = time.Now()
app.Copyright = "(c) " + strconv.Itoa(time.Now().Year()) + " Layotto Authors"
app.Usage = "A fast and efficient cloud native application runtime based on MOSN."
app.Flags = cmdStart.Flags
// commands
app.Commands = []cli.Command{
cmdStart,
cmdStop,
cmdReload,
}
// action
app.Action = func(c *cli.Context) error {
if c.NumFlags() == 0 {
return cli.ShowAppHelp(c)
}
return startCmd.Action.(func(c *cli.Context) error)(c)
}
return app
}