-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add admin api server skeleton (#330) * feat(config): add config updater api (#336) * add http server api for cluster. (#352) * add http server api for tenant (#366) * add http server api for tenant * fix import format * fix go format Co-authored-by: Zhang Aphelios <aphelios.zhang@shopee.com> * add http api for nodes#344 (#371) * add http api for nodes * fix:bug * fix:bug * fix:bug * fix:bug * feat: add arana-admin into docker compose file * fix 🐛 HTTP API For UI (#399) * change * change * feat(config): support new config & Feat config listener (#374) * feat: add group api for UI module #344 (#373) * add: missing interfaces in proto files and discovery files * feat: group api in file db_groups.go (#344) * style: add license header and add tool: imports-formatter * style: fix import * feat: support notify event * refactor:config center * none * feat: none * refactor:split config and add change watch * style: fix code style * fix: fix func call error * fix: ci error * style:fix code style * fix: fix code style * refactor: rebase upstream * fix:add cluster info to list groups Co-authored-by: chovychan <51713304+chovychan@users.noreply.github.com> Co-authored-by: Jeffsky <jjeffcaii@outlook.com> * fix: compile failure * fix:unit test (#403) * Feat/admin api (#404) * Feat/admin api (#406) * fix:unit test * fix:unit test * fix:file unit test Co-authored-by: Zonglei Dong <dongzonglei@apache.org> Co-authored-by: Aphelios <996933971@qq.com> Co-authored-by: Zhang Aphelios <aphelios.zhang@shopee.com> Co-authored-by: 龚娜 <2036479155@qq.com> Co-authored-by: liaochuntao <liaochuntao@live.com> Co-authored-by: chovychan <51713304+chovychan@users.noreply.github.com>
- Loading branch information
1 parent
4052423
commit 3dcd8ab
Showing
49 changed files
with
4,448 additions
and
1,380 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 admin | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
import ( | ||
"github.com/arana-db/arana/cmd/cmds" | ||
"github.com/arana-db/arana/pkg/admin" | ||
_ "github.com/arana-db/arana/pkg/admin/router" | ||
"github.com/arana-db/arana/pkg/boot" | ||
"github.com/arana-db/arana/pkg/constants" | ||
"github.com/arana-db/arana/pkg/util/log" | ||
) | ||
|
||
const ( | ||
_keyPort = "port" | ||
_defaultPort = 8080 | ||
) | ||
|
||
func init() { | ||
cmd := &cobra.Command{ | ||
Use: "admin", | ||
Short: "admin", | ||
Example: "arana admin -c bootstrap.yaml -p 8080", | ||
RunE: run, | ||
} | ||
cmd.PersistentFlags(). | ||
StringP(constants.ConfigPathKey, "c", os.Getenv(constants.EnvBootstrapPath), "bootstrap configuration file path") | ||
cmd.PersistentFlags(). | ||
Uint16P(_keyPort, "p", _defaultPort, "listen port") | ||
|
||
cmds.Handle(func(root *cobra.Command) { | ||
root.AddCommand(cmd) | ||
}) | ||
} | ||
|
||
func Run(bootstrapPath string, addr string) error { | ||
discovery := boot.NewDiscovery(bootstrapPath) | ||
if err := discovery.Init(context.Background()); err != nil { | ||
log.Fatal("start admin api server failed: %v", err) | ||
return err | ||
} | ||
adminServer := admin.New(discovery) | ||
return adminServer.Listen(addr) | ||
} | ||
|
||
func run(cmd *cobra.Command, args []string) error { | ||
_ = args | ||
btPath, _ := cmd.PersistentFlags().GetString(constants.ConfigPathKey) | ||
port, _ := cmd.PersistentFlags().GetUint16("port") | ||
if len(btPath) < 1 { | ||
// search bootstrap yaml | ||
for _, path := range constants.GetConfigSearchPathList() { | ||
btPath = filepath.Join(path, "bootstrap.yaml") | ||
if _, err := os.Stat(btPath); err == nil { | ||
break | ||
} | ||
btPath = filepath.Join(path, "bootstrap.yml") | ||
if _, err := os.Stat(btPath); err == nil { | ||
break | ||
} | ||
} | ||
} | ||
|
||
return Run(btPath, fmt.Sprintf(":%d", port)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You 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. | ||
# | ||
|
||
config: | ||
name: etcd | ||
options: | ||
endpoints: "http://127.0.0.1:2379" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.