mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-10-26 13:12:12 +08:00
update const quote.
This commit is contained in:
parent
248dc2df7c
commit
2923b625eb
@ -26,7 +26,7 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
conf "github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
kdisc "github.com/openimsdk/open-im-server/v3/pkg/common/discoveryregister"
|
kdisc "github.com/openimsdk/open-im-server/v3/pkg/common/discoveryregister"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/prommetrics"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/prommetrics"
|
||||||
"github.com/openimsdk/tools/discovery"
|
"github.com/openimsdk/tools/discovery"
|
||||||
@ -41,9 +41,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
API config.API
|
API conf.API
|
||||||
Share config.Share
|
Share conf.Share
|
||||||
Discovery config.Discovery
|
Discovery conf.Discovery
|
||||||
|
|
||||||
RuntimeEnv string
|
RuntimeEnv string
|
||||||
}
|
}
|
||||||
@ -86,7 +86,7 @@ func Start(ctx context.Context, index int, config *Config) error {
|
|||||||
return listener, port, nil
|
return listener, port, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.API.Prometheus.AutoSetPorts && config.Discovery.Enable != kdisc.Etcd {
|
if config.API.Prometheus.AutoSetPorts && config.Discovery.Enable != conf.ETCD {
|
||||||
return errs.New("only etcd support autoSetPorts", "RegisterName", "api").Wrap()
|
return errs.New("only etcd support autoSetPorts", "RegisterName", "api").Wrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,8 +2,10 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/discoveryregister"
|
conf "github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/prommetrics"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/prommetrics"
|
||||||
"github.com/openimsdk/tools/apiresp"
|
"github.com/openimsdk/tools/apiresp"
|
||||||
"github.com/openimsdk/tools/discovery"
|
"github.com/openimsdk/tools/discovery"
|
||||||
@ -11,7 +13,6 @@ import (
|
|||||||
"github.com/openimsdk/tools/errs"
|
"github.com/openimsdk/tools/errs"
|
||||||
"github.com/openimsdk/tools/log"
|
"github.com/openimsdk/tools/log"
|
||||||
clientv3 "go.etcd.io/etcd/client/v3"
|
clientv3 "go.etcd.io/etcd/client/v3"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type PrometheusDiscoveryApi struct {
|
type PrometheusDiscoveryApi struct {
|
||||||
@ -23,14 +24,14 @@ func NewPrometheusDiscoveryApi(config *Config, client discovery.SvcDiscoveryRegi
|
|||||||
api := &PrometheusDiscoveryApi{
|
api := &PrometheusDiscoveryApi{
|
||||||
config: config,
|
config: config,
|
||||||
}
|
}
|
||||||
if config.Discovery.Enable == discoveryregister.Etcd {
|
if config.Discovery.Enable == conf.ETCD {
|
||||||
api.client = client.(*etcd.SvcDiscoveryRegistryImpl).GetClient()
|
api.client = client.(*etcd.SvcDiscoveryRegistryImpl).GetClient()
|
||||||
}
|
}
|
||||||
return api
|
return api
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PrometheusDiscoveryApi) Enable(c *gin.Context) {
|
func (p *PrometheusDiscoveryApi) Enable(c *gin.Context) {
|
||||||
if p.config.Discovery.Enable != discoveryregister.Etcd {
|
if p.config.Discovery.Enable != conf.ETCD {
|
||||||
c.JSON(http.StatusOK, []struct{}{})
|
c.JSON(http.StatusOK, []struct{}{})
|
||||||
c.Abort()
|
c.Abort()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,7 +37,7 @@ import (
|
|||||||
"github.com/openimsdk/tools/utils/datautil"
|
"github.com/openimsdk/tools/utils/datautil"
|
||||||
"github.com/openimsdk/tools/utils/runtimeenv"
|
"github.com/openimsdk/tools/utils/runtimeenv"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
conf "github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
discRegister "github.com/openimsdk/open-im-server/v3/pkg/common/discoveryregister"
|
discRegister "github.com/openimsdk/open-im-server/v3/pkg/common/discoveryregister"
|
||||||
kdisc "github.com/openimsdk/open-im-server/v3/pkg/common/discoveryregister"
|
kdisc "github.com/openimsdk/open-im-server/v3/pkg/common/discoveryregister"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/controller"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/controller"
|
||||||
@ -64,13 +64,13 @@ type MsgTransfer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
MsgTransfer config.MsgTransfer
|
MsgTransfer conf.MsgTransfer
|
||||||
RedisConfig config.Redis
|
RedisConfig conf.Redis
|
||||||
MongodbConfig config.Mongo
|
MongodbConfig conf.Mongo
|
||||||
KafkaConfig config.Kafka
|
KafkaConfig conf.Kafka
|
||||||
Share config.Share
|
Share conf.Share
|
||||||
WebhooksConfig config.Webhooks
|
WebhooksConfig conf.Webhooks
|
||||||
Discovery config.Discovery
|
Discovery conf.Discovery
|
||||||
}
|
}
|
||||||
|
|
||||||
func Start(ctx context.Context, index int, config *Config) error {
|
func Start(ctx context.Context, index int, config *Config) error {
|
||||||
@ -168,7 +168,7 @@ func (m *MsgTransfer) Start(index int, config *Config) error {
|
|||||||
return listener, port, nil
|
return listener, port, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.MsgTransfer.Prometheus.AutoSetPorts && config.Discovery.Enable != kdisc.Etcd {
|
if config.MsgTransfer.Prometheus.AutoSetPorts && config.Discovery.Enable != conf.ETCD {
|
||||||
return errs.New("only etcd support autoSetPorts", "RegisterName", "api").Wrap()
|
return errs.New("only etcd support autoSetPorts", "RegisterName", "api").Wrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,7 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
conf "github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
"github.com/openimsdk/tools/discovery/etcd"
|
"github.com/openimsdk/tools/discovery/etcd"
|
||||||
"github.com/openimsdk/tools/utils/datautil"
|
"github.com/openimsdk/tools/utils/datautil"
|
||||||
"github.com/openimsdk/tools/utils/jsonutil"
|
"github.com/openimsdk/tools/utils/jsonutil"
|
||||||
@ -46,8 +46,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Start rpc server.
|
// Start rpc server.
|
||||||
func Start[T any](ctx context.Context, discovery *config.Discovery, prometheusConfig *config.Prometheus, listenIP,
|
func Start[T any](ctx context.Context, discovery *conf.Discovery, prometheusConfig *conf.Prometheus, listenIP,
|
||||||
registerIP string, autoSetPorts bool, rpcPorts []int, index int, rpcRegisterName string, share *config.Share, config T, rpcFn func(ctx context.Context,
|
registerIP string, autoSetPorts bool, rpcPorts []int, index int, rpcRegisterName string, share *conf.Share, config T, rpcFn func(ctx context.Context,
|
||||||
config T, client discovery.SvcDiscoveryRegistry, server *grpc.Server) error, options ...grpc.ServerOption) error {
|
config T, client discovery.SvcDiscoveryRegistry, server *grpc.Server) error, options ...grpc.ServerOption) error {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -84,7 +84,7 @@ func Start[T any](ctx context.Context, discovery *config.Discovery, prometheusCo
|
|||||||
return listener, port, nil
|
return listener, port, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if autoSetPorts && discovery.Enable != kdisc.Etcd {
|
if autoSetPorts && discovery.Enable != conf.ETCD {
|
||||||
return errs.New("only etcd support autoSetPorts", "rpcRegisterName", rpcRegisterName).Wrap()
|
return errs.New("only etcd support autoSetPorts", "rpcRegisterName", rpcRegisterName).Wrap()
|
||||||
}
|
}
|
||||||
client, err := kdisc.NewDiscoveryRegister(discovery, runTimeEnv)
|
client, err := kdisc.NewDiscoveryRegister(discovery, runTimeEnv)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user