-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from airdb/dev
dev
- Loading branch information
Showing
12 changed files
with
157 additions
and
12 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
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
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,16 @@ | ||
package adblib | ||
|
||
import ( | ||
"github.com/MakeNowJust/heredoc" | ||
) | ||
|
||
var ( | ||
DNSSrvDoc = heredoc.Doc(` | ||
$ adb srv add _sip._tcp "10 60 443 bigbox.airdb.red" | ||
$ adb srv add _sip._tcp "10 20 443 smallbox1.airdb.blue" | ||
$ adb srv add _sip._tcp "10 20 443 smallbox2.airdb.green" | ||
$ adb srv add _sip._tcp "20 0 443 backup.airdb.black" | ||
> Refer: https://zh.wikipedia.org/wiki/SRV记录 | ||
`) | ||
) |
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,11 @@ | ||
package adblib | ||
|
||
import ( | ||
"github.com/MakeNowJust/heredoc" | ||
) | ||
|
||
var ( | ||
SqlDoc = heredoc.Doc(` | ||
adb mysql mina-api -uroot -ppasswd --db test | ||
`) | ||
) |
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,91 @@ | ||
package adblib | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
clb "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb/v20180317" | ||
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common" | ||
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors" | ||
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile" | ||
) | ||
|
||
const CLBEndpoint = "clb.tencentcloudapi.com" | ||
|
||
type Client struct { | ||
*clb.Client | ||
} | ||
|
||
func NewCLBClient() (*Client, error) { | ||
secretID := os.Getenv("TENCENTCLOUD_SECRET_ID") | ||
secretKey := os.Getenv("TENCENTCLOUD_SECRET_KEY") | ||
region := os.Getenv("TENCENTCLOUD_REGION") | ||
|
||
credential := common.NewCredential(secretID, secretKey) | ||
|
||
cpf := profile.NewClientProfile() | ||
cpf.HttpProfile.Endpoint = CLBEndpoint | ||
|
||
client, err := clb.NewClient(credential, region, cpf) | ||
|
||
return &Client{ | ||
client, | ||
}, err | ||
} | ||
|
||
func (client *Client) ListCLB() { | ||
request := clb.NewDescribeLoadBalancersRequest() | ||
|
||
params := "{}" | ||
err := request.FromJsonString(params) | ||
if err != nil { | ||
panic(err) | ||
} | ||
response, err := client.DescribeLoadBalancers(request) | ||
if _, ok := err.(*errors.TencentCloudSDKError); ok { | ||
fmt.Printf("An API error has returned: %s", err) | ||
return | ||
} | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
for _, lbSet := range response.Response.LoadBalancerSet { | ||
// fmt.Println(*lbSet.LoadBalancerId) | ||
client.ShowRS(*lbSet.LoadBalancerId) | ||
} | ||
} | ||
|
||
func (client *Client) ShowRS(lbID string) { | ||
|
||
request := clb.NewDescribeTargetsRequest() | ||
|
||
params := fmt.Sprintf("{\"LoadBalancerId\":\"%s\"}", lbID) | ||
err := request.FromJsonString(params) | ||
if err != nil { | ||
panic(err) | ||
} | ||
response, err := client.DescribeTargets(request) | ||
if _, ok := err.(*errors.TencentCloudSDKError); ok { | ||
fmt.Printf("An API error has returned: %s", err) | ||
return | ||
} | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// fmt.Printf("%s", response.ToJsonString()) | ||
for _, listener := range response.Response.Listeners { | ||
for _, rule := range listener.Rules { | ||
for _, target := range rule.Targets { | ||
fmt.Printf("%s%s\t%d\t%s\t%s\n", | ||
*rule.Domain, | ||
*rule.Url, | ||
*target.Weight, | ||
*target.InstanceId, | ||
*target.InstanceName, | ||
) | ||
} | ||
} | ||
} | ||
} |
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