Skip to content

Commit

Permalink
docs: add openim flag
Browse files Browse the repository at this point in the history
Signed-off-by: Xinwei Xiong(cubxxw) <[email protected]>
  • Loading branch information
cubxxw committed Oct 23, 2023
1 parent 39b2515 commit dd14dba
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 27 deletions.
6 changes: 3 additions & 3 deletions cmd/api/chat-api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ package main
import (
"flag"
"fmt"
"github.com/OpenIMSDK/chat/pkg/discovery_register"
"github.com/OpenIMSDK/chat/tools/component"
"github.com/OpenIMSDK/tools/discoveryregistry"
"math/rand"
"net"
"strconv"
"time"

"github.com/OpenIMSDK/chat/pkg/discovery_register"
"github.com/OpenIMSDK/tools/discoveryregistry"

"github.com/OpenIMSDK/chat/tools/component"

mw2 "github.com/OpenIMSDK/chat/pkg/common/mw"
Expand Down
2 changes: 1 addition & 1 deletion internal/rpc/admin/ip_forbidden.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ package admin

import (
"context"
"time"
"github.com/OpenIMSDK/tools/log"
"time"

admin2 "github.com/OpenIMSDK/chat/pkg/common/db/table/admin"
"github.com/OpenIMSDK/chat/pkg/common/mctx"
Expand Down
2 changes: 1 addition & 1 deletion internal/rpc/admin/register_add_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
"strings"
"time"

"github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/tools/utils"

admin2 "github.com/OpenIMSDK/chat/pkg/common/db/table/admin"
Expand Down
4 changes: 2 additions & 2 deletions internal/rpc/admin/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ package admin

import (
"context"
"strings"
"time"
"github.com/OpenIMSDK/chat/pkg/common/constant"
"github.com/OpenIMSDK/tools/log"
"strings"
"time"

"github.com/OpenIMSDK/protocol/wrapperspb"
"github.com/OpenIMSDK/tools/errs"
Expand Down
2 changes: 1 addition & 1 deletion internal/rpc/admin/user_ip_limit_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ package admin

import (
"context"
"time"
"github.com/OpenIMSDK/tools/log"
"time"

"github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/utils"
Expand Down
10 changes: 5 additions & 5 deletions pkg/common/chatrpcstart/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ package chatrpcstart

import (
"fmt"
"net"
"strconv"

"github.com/OpenIMSDK/chat/pkg/common/config"
chatMw "github.com/OpenIMSDK/chat/pkg/common/mw"
"github.com/OpenIMSDK/chat/pkg/discovery_register"
Expand All @@ -26,8 +29,6 @@ import (
"github.com/OpenIMSDK/tools/utils"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"net"
"strconv"
)

func Start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error, options ...grpc.ServerOption) error {
Expand All @@ -38,11 +39,10 @@ func Start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(c
/*
zkClient, err := openKeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema,
openKeeper.WithFreq(time.Hour), openKeeper.WithUserNameAndPassword(config.Config.Zookeeper.Username,
config.Config.Zookeeper.Password), openKeeper.WithRoundRobin(), openKeeper.WithTimeout(10), openKeeper.WithLogger(log.NewZkLogger()))*/
if err != nil {
config.Config.Zookeeper.Password), openKeeper.WithRoundRobin(), openKeeper.WithTimeout(10), openKeeper.WithLogger(log.NewZkLogger()))*/if err != nil {
return errs.Wrap(err)
}
//defer zkClient.CloseZK()
// defer zkClient.CloseZK()
zkClient.AddOption(chatMw.AddUserType(), mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials()))
registerIP, err := network.GetRpcRegisterIP(config.Config.Rpc.RegisterIP)
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions pkg/common/config/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ import (
"bytes"
"errors"
"fmt"
"github.com/OpenIMSDK/protocol/constant"
openKeeper "github.com/OpenIMSDK/tools/discoveryregistry/zookeeper"
"os"
"path/filepath"
"runtime"
"time"

"github.com/OpenIMSDK/protocol/constant"
openKeeper "github.com/OpenIMSDK/tools/discoveryregistry/zookeeper"

"github.com/OpenIMSDK/tools/utils"
"gopkg.in/yaml.v3"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/common/db/model/admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"context"
"crypto/md5"
"encoding/hex"
"time"
"github.com/OpenIMSDK/tools/log"
"time"

"github.com/OpenIMSDK/chat/pkg/common/config"
"github.com/OpenIMSDK/chat/pkg/common/db/table/admin"
Expand Down
2 changes: 1 addition & 1 deletion pkg/common/db/model/chat/user_login_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ package chat

import (
"context"
"time"
"github.com/OpenIMSDK/tools/errs"
"time"

"gorm.io/gorm"

Expand Down
20 changes: 11 additions & 9 deletions pkg/discovery_register/k8s_discovery_register.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import (
"context"
"errors"
"fmt"
"time"

"github.com/OpenIMSDK/chat/pkg/common/config"
"github.com/OpenIMSDK/tools/discoveryregistry"
openkeeper "github.com/OpenIMSDK/tools/discoveryregistry/zookeeper"
"github.com/OpenIMSDK/tools/log"
"google.golang.org/grpc"
"time"
)

func NewDiscoveryRegister(envType string) (discoveryregistry.SvcDiscoveryRegistry, error) {
Expand Down Expand Up @@ -44,44 +45,45 @@ func (cli *K8sDR) Register(serviceName, host string, port int, opts ...grpc.Dial
cli.rpcRegisterAddr = serviceName
return nil
}
func (cli *K8sDR) UnRegister() error {

func (cli *K8sDR) UnRegister() error {
return nil
}
func (cli *K8sDR) CreateRpcRootNodes(serviceNames []string) error {

func (cli *K8sDR) CreateRpcRootNodes(serviceNames []string) error {
return nil
}
func (cli *K8sDR) RegisterConf2Registry(key string, conf []byte) error {

func (cli *K8sDR) RegisterConf2Registry(key string, conf []byte) error {
return nil
}

func (cli *K8sDR) GetConfFromRegistry(key string) ([]byte, error) {

return nil, nil
}
func (cli *K8sDR) GetConns(ctx context.Context, serviceName string, opts ...grpc.DialOption) ([]*grpc.ClientConn, error) {

func (cli *K8sDR) GetConns(ctx context.Context, serviceName string, opts ...grpc.DialOption) ([]*grpc.ClientConn, error) {
conn, err := grpc.DialContext(ctx, serviceName, append(cli.options, opts...)...)
return []*grpc.ClientConn{conn}, err
}
func (cli *K8sDR) GetConn(ctx context.Context, serviceName string, opts ...grpc.DialOption) (*grpc.ClientConn, error) {

func (cli *K8sDR) GetConn(ctx context.Context, serviceName string, opts ...grpc.DialOption) (*grpc.ClientConn, error) {
return grpc.DialContext(ctx, serviceName, append(cli.options, opts...)...)
}
func (cli *K8sDR) GetSelfConnTarget() string {

func (cli *K8sDR) GetSelfConnTarget() string {
return cli.rpcRegisterAddr
}

func (cli *K8sDR) AddOption(opts ...grpc.DialOption) {
cli.options = append(cli.options, opts...)
}

func (cli *K8sDR) CloseConn(conn *grpc.ClientConn) {
conn.Close()
}

// do not use this method for call rpc
// do not use this method for call rpc.
func (cli *K8sDR) GetClientLocalConns() map[string][]*grpc.ClientConn {
fmt.Println("should not call this function!!!!!!!!!!!!!!!!!!!!!!!!!")
return nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/sms/sms.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ package sms
import (
"context"
"fmt"
"strings"
"github.com/OpenIMSDK/chat/pkg/common/config"
"strings"
)

func New() (SMS, error) {
Expand Down

0 comments on commit dd14dba

Please sign in to comment.