Skip to content

Commit

Permalink
增加说明文档介绍
Browse files Browse the repository at this point in the history
  • Loading branch information
snowlyg committed Dec 26, 2021
1 parent f6fe045 commit baf6a54
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
46 changes: 46 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
======== for redis driver ==============
options := &redis.UniversalOptions{
Addrs: []string{"127.0.0.1:6379"},
Password: "",
PoolSize: 10,
IdleTimeout: 300 * time.Second,
// Dialer: func(ctx context.Context, network, addr string) (net.Conn, error) {
// conn, err := net.Dial(network, addr)
// if err == nil {
// go func() {
// time.Sleep(5 * time.Second)
// conn.Close()
// }()
// }
// return conn, err
// },
}
err := multi.InitDriver(&multi.Config{
DriverType: "redis",
TokenMaxCount: 10,
UniversalClient: redis.NewUniversalClient(options)})
if err != nil {
panic(err)
}
======== for local driver ==============
err := multi.InitDriver(&multi.Config{
DriverType: "local"
if err != nil {
panic(err)
}
======== for jwt driver ==============
err := multi.InitDriver(&multi.Config{
DriverType: "jwt",
HmacSecret: "your hmac_secret",
if err != nil {
panic(err)
}
*/

package multi
3 changes: 2 additions & 1 deletion gin/example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

// init 初始化认证驱动
// 驱动类型: 可选 redis ,local
// 驱动类型: 可选 redis ,local,jwt
func init() {
options := &redis.UniversalOptions{
Addrs: []string{"127.0.0.1:6379"},
Expand All @@ -33,6 +33,7 @@ func init() {

err := multi.InitDriver(&multi.Config{
DriverType: "redis",
TokenMaxCount: 10,
UniversalClient: redis.NewUniversalClient(options)})
if err != nil {
panic(fmt.Sprintf("auth is not init get err %v\n", err))
Expand Down
3 changes: 2 additions & 1 deletion iris/example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

// init 初始化认证驱动
// 驱动类型: 可选 redis ,local
// 驱动类型: 可选 redis ,local,jwt
func init() {
options := &redis.UniversalOptions{
Addrs: []string{"127.0.0.1:6379"},
Expand All @@ -33,6 +33,7 @@ func init() {

err := multi.InitDriver(&multi.Config{
DriverType: "redis",
TokenMaxCount: 10,
UniversalClient: redis.NewUniversalClient(options)})
if err != nil {
panic(fmt.Sprintf("auth is not init get err %v\n", err))
Expand Down

0 comments on commit baf6a54

Please sign in to comment.