Skip to content

Commit eb51353

Browse files
authored
feat: add data loader framework (#2371)
1 parent 7c5eced commit eb51353

File tree

1 file changed

+44
-0
lines changed
  • api/internal/handler/data_loader/loader

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package loader
18+
19+
import "github.com/apisix/manager-api/internal/core/entity"
20+
21+
// DataSets are intermediate structures used to handle
22+
// import and export data with APISIX entities.
23+
// On import, raw data will be parsed as DataSets
24+
// On export, DataSets will be encoded to raw data
25+
type DataSets struct {
26+
Routes []entity.Route
27+
Upstreams []entity.Upstream
28+
Services []entity.Service
29+
Consumers []entity.Consumer
30+
SSLs []entity.SSL
31+
StreamRoutes []entity.StreamRoute
32+
GlobalPlugins []entity.GlobalPlugins
33+
PluginConfigs []entity.PluginConfig
34+
Protos []entity.Proto
35+
}
36+
37+
// Loader provide data loader abstraction
38+
type Loader interface {
39+
// Import accepts data and converts it into entity data sets
40+
Import(input interface{}) (*DataSets, error)
41+
42+
// Export accepts entity data sets and converts it into a specific format
43+
Export(data DataSets) (interface{}, error)
44+
}

0 commit comments

Comments
 (0)