Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(oss api): support ceph oss #775

Merged
merged 30 commits into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
73d023b
feat(oss api): support ceph oss
wlwilliamx Aug 30, 2022
d705b73
feat(oss api): support ceph oss
wlwilliamx Aug 30, 2022
228b281
chore(ceph oss test): update ceph oss test
wlwilliamx Aug 30, 2022
a9d99b7
Merge branch 'main' into dev
wenxuwan Aug 30, 2022
e71cce9
chore: update goimports
wlwilliamx Aug 30, 2022
5ae0a2d
Merge remote-tracking branch 'main' into dev
wlwilliamx Aug 30, 2022
2e2e288
style: format code
wlwilliamx Aug 30, 2022
2e66fb3
Merge branch 'main' into dev
seeflood Sep 8, 2022
60d0aee
style(ceph): format code
wlwilliamx Sep 16, 2022
e556fc0
Merge remote-tracking branch 'fork/dev' into dev
wlwilliamx Sep 16, 2022
8aa327e
chore(proto): regenerate proto code
wlwilliamx Sep 16, 2022
995dde7
Merge remote-tracking branch 'origin/main' into dev
wlwilliamx Sep 17, 2022
1d2be8a
fix(typo): fix a typo
wlwilliamx Sep 17, 2022
24356a5
fix(typo): fix a typo
wlwilliamx Sep 22, 2022
7b3d8f5
fix(typo): fix a typo
wlwilliamx Sep 22, 2022
9919f23
Merge branch 'main' into dev
wenxuwan Oct 9, 2022
fd653b2
test(oss): add some UT
wlwilliamx Oct 10, 2022
f7b8e60
fix(typo): fix a typo
wlwilliamx Oct 10, 2022
562a93b
Merge branch 'main' into dev
seeflood Oct 10, 2022
36fbd9c
Merge branch 'main' into dev
seeflood Oct 12, 2022
ef7f469
chore(goimports): goimports
wlwilliamx Oct 13, 2022
f01edc8
Merge branch 'main' into dev
wlwilliamx Oct 13, 2022
e3c9ac3
chore(goimports): goimports
wlwilliamx Oct 13, 2022
6537c0b
test(oss): add some UT
wlwilliamx Oct 13, 2022
98581ed
chore(goimports): goimports file
wlwilliamx Oct 13, 2022
754058f
chore(oss): extract output functions and add UT for these functions
wlwilliamx Oct 13, 2022
0928526
Update cmd/layotto/main.go
seeflood Oct 13, 2022
3818890
Update cmd/layotto_without_xds/main.go
seeflood Oct 13, 2022
cb4356a
Update cmd/layotto_multiple_api/main.go
seeflood Oct 13, 2022
fa62804
Merge branch 'main' into dev
seeflood Oct 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ cmd/layotto_multiple_api/nohup.out
default.etcd/
demo/configuration/common/client
demo/file/client
demo/oss/client
demo/flowcontrol/client
demo/lock/redis/client
demo/pubsub/redis/client/publisher
Expand Down
3 changes: 3 additions & 0 deletions cmd/layotto/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import (

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"
Expand Down Expand Up @@ -290,6 +292,7 @@ func NewRuntimeGrpcServer(data json.RawMessage, opts ...grpc.ServerOption) (mgrp
runtime.WithOssFactory(
oss.NewFactory("aws.oss", aws_oss.NewAwsOss),
oss.NewFactory("aliyun.oss", aliyun_oss.NewAliyunOss),
oss.NewFactory("ceph.oss", ceph_oss.NewCephOss),
seeflood marked this conversation as resolved.
Show resolved Hide resolved
),
// PubSub
runtime.WithPubSubFactory(
Expand Down
3 changes: 3 additions & 0 deletions cmd/layotto_multiple_api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import (

aliyun_oss "mosn.io/layotto/components/oss/aliyun"

ceph_oss "mosn.io/layotto/components/oss/ceph"

aliyun_file "mosn.io/layotto/components/file/aliyun"
"mosn.io/layotto/components/file/local"

Expand Down Expand Up @@ -304,6 +306,7 @@ func NewRuntimeGrpcServer(data json.RawMessage, opts ...grpc.ServerOption) (mgrp
runtime.WithOssFactory(
oss.NewFactory("aws.oss", aws_oss.NewAwsOss),
oss.NewFactory("aliyun.oss", aliyun_oss.NewAliyunOss),
oss.NewFactory("ceph.oss", ceph_oss.NewCephOss),
seeflood marked this conversation as resolved.
Show resolved Hide resolved
),

// PubSub
Expand Down
3 changes: 3 additions & 0 deletions cmd/layotto_without_xds/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import (

aliyun_oss "mosn.io/layotto/components/oss/aliyun"

ceph_oss "mosn.io/layotto/components/oss/ceph"

"mosn.io/layotto/components/file/aliyun"
aws_file "mosn.io/layotto/components/file/aws"
"mosn.io/layotto/components/file/minio"
Expand Down Expand Up @@ -408,6 +410,7 @@ func NewRuntimeGrpcServer(data json.RawMessage, opts ...grpc.ServerOption) (mgrp
runtime.WithOssFactory(
oss.NewFactory("aws.oss", aws_oss.NewAwsOss),
oss.NewFactory("aliyun.oss", aliyun_oss.NewAliyunOss),
oss.NewFactory("ceph.oss", ceph_oss.NewCephOss),
seeflood marked this conversation as resolved.
Show resolved Hide resolved
),

// Sequencer
Expand Down
43 changes: 43 additions & 0 deletions components/oss/ceph/option.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* 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 ceph

import (
"time"

"github.com/jinzhu/copier"
)

var (
int642time = copier.TypeConverter{
SrcType: int64(0),
wlwilliamx marked this conversation as resolved.
Show resolved Hide resolved
DstType: &time.Time{},
Fn: func(src interface{}) (interface{}, error) {
s, _ := src.(int64)
t := time.Unix(s, 0)
return &t, nil
},
}
time2int64 = copier.TypeConverter{
SrcType: &time.Time{},
DstType: int64(0),
Fn: func(src interface{}) (interface{}, error) {
s, _ := src.(*time.Time)
return s.Unix(), nil
},
}
)
52 changes: 52 additions & 0 deletions components/oss/ceph/option_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* 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 ceph

import (
"testing"
"time"

"github.com/stretchr/testify/assert"

"github.com/jinzhu/copier"
)

func TestCopierOption(t *testing.T) {
type ValueWithInt64 struct {
TestString string
TestInt64toTime int64
}

type ValueWithTimer struct {
TestString *string
TestInt64toTime *time.Time
}
timer := time.Now().Unix()
srcValue := &ValueWithInt64{TestInt64toTime: timer}
destValue := &ValueWithTimer{}
err := copier.CopyWithOption(destValue, srcValue, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: []copier.TypeConverter{int642time}})
assert.Nil(t, err)
assert.Nil(t, destValue.TestString)
assert.Equal(t, timer, destValue.TestInt64toTime.Unix())

ti := time.Now()
src := &ValueWithTimer{TestInt64toTime: &ti}
dst := &ValueWithInt64{}
err = copier.CopyWithOption(dst, src, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: []copier.TypeConverter{time2int64}})
assert.Nil(t, err)
assert.Equal(t, ti.Unix(), dst.TestInt64toTime)
}
Loading