Skip to content

Commit

Permalink
WTEL-4439
Browse files Browse the repository at this point in the history
  • Loading branch information
i.navrotskyj committed Apr 8, 2024
1 parent 175dce8 commit d1463ef
Show file tree
Hide file tree
Showing 19 changed files with 1,599 additions and 315 deletions.
2 changes: 1 addition & 1 deletion app/agent.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package app

import (
workflow "buf.build/gen/go/webitel/workflow/protocolbuffers/go"
"context"
"github.com/webitel/call_center/agent_manager"
"github.com/webitel/call_center/model"
"github.com/webitel/protos/workflow"
"github.com/webitel/wlog"
"net/http"
"strconv"
Expand Down
7 changes: 4 additions & 3 deletions external_commands/grpc/call_connection.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package grpc

import (
fsgrpc "buf.build/gen/go/webitel/fs/grpc/go/_gogrpc"
fs "buf.build/gen/go/webitel/fs/protocolbuffers/go"
"context"
"fmt"
"github.com/webitel/call_center/model"
"github.com/webitel/call_center/utils"
"github.com/webitel/protos/fs"
"google.golang.org/grpc"
"google.golang.org/grpc/connectivity"
"net/http"
Expand Down Expand Up @@ -100,7 +101,7 @@ type CallConnection struct {
host string
rateLimiter *utils.RateLimiter
client *grpc.ClientConn
api fs.ApiClient
api fsgrpc.ApiClient
cdrUri string
}

Expand All @@ -117,7 +118,7 @@ func NewCallConnection(name, url string) (*CallConnection, *model.AppError) {
return nil, model.NewAppError("NewCallConnection", "grpc.create_connection.app_error", nil, err.Error(), http.StatusInternalServerError)
}

c.api = fs.NewApiClient(c.client)
c.api = fsgrpc.NewApiClient(c.client)
return c, nil
}

Expand Down
25 changes: 16 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,50 @@ module github.com/webitel/call_center
go 1.19

require (
buf.build/gen/go/webitel/cc/grpc/go v1.3.0-20240404135440-3efb61ebef03.2
buf.build/gen/go/webitel/cc/protocolbuffers/go v1.33.0-20240404135440-3efb61ebef03.1
buf.build/gen/go/webitel/fs/grpc/go v1.3.0-20240404140117-b025f673b11a.2
buf.build/gen/go/webitel/fs/protocolbuffers/go v1.33.0-20240404140117-b025f673b11a.1
buf.build/gen/go/webitel/workflow/protocolbuffers/go v1.33.0-20240404140117-0cc0abc10b4f.1
github.com/go-gorp/gorp v2.2.0+incompatible
github.com/lib/pq v1.10.9
github.com/olebedev/emitter v0.0.0-20190110104742-e8d1457e6aee
github.com/pborman/uuid v1.2.1
github.com/pkg/errors v0.9.1
github.com/streadway/amqp v1.1.0
github.com/webitel/engine v0.0.0-20240327135406-7469d4bcb04b
github.com/webitel/flow_manager v0.0.0-20240318151852-e35870a75700
github.com/webitel/protos/cc v0.0.0-20240401125538-65d07de06373
github.com/webitel/protos/fs v0.0.0-20240327130525-7501c51c7a8e
github.com/webitel/protos/workflow v0.0.0-20240327132302-ffcc68b6314f
github.com/webitel/engine v0.0.0-20240408093415-335bcd6ed982
github.com/webitel/flow_manager v0.0.0-20240408094010-b21a163cab0c
github.com/webitel/wlog v0.0.0-20220608103744-93b33e61bd28
golang.org/x/sync v0.4.0
golang.org/x/time v0.0.0-20220411224347-583f2d630306
golang.org/x/time v0.1.0
google.golang.org/grpc v1.58.3
)

require (
buf.build/gen/go/grpc-ecosystem/grpc-gateway/protocolbuffers/go v1.33.0-20231027202514-3f42134f4c56.1 // indirect
buf.build/gen/go/webitel/chat/grpc/go v1.3.0-20240402124150-079f64c1d382.2 // indirect
buf.build/gen/go/webitel/chat/protocolbuffers/go v1.33.0-20240402124150-079f64c1d382.1 // indirect
buf.build/gen/go/webitel/engine/protocolbuffers/go v1.33.0-20240402125447-cb375844242f.1 // indirect
buf.build/gen/go/webitel/workflow/grpc/go v1.3.0-20240404140117-0cc0abc10b4f.2 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 // indirect
github.com/hashicorp/consul/api v1.25.1 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/hashicorp/serf v0.10.1 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/nicksnyder/go-i18n v1.10.1 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/webitel/protos/engine v0.0.0-20240327132302-ffcc68b6314f // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
Expand All @@ -53,7 +59,8 @@ require (
google.golang.org/genproto v0.0.0-20231012201019-e917dd12ba7a // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231012201019-e917dd12ba7a // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231012201019-e917dd12ba7a // indirect
google.golang.org/protobuf v1.31.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
5 changes: 3 additions & 2 deletions grpc_api/agent.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package grpc_api

import (
grpc "buf.build/gen/go/webitel/cc/grpc/go/_gogrpc"
cc "buf.build/gen/go/webitel/cc/protocolbuffers/go"
"context"
"github.com/webitel/call_center/app"
"github.com/webitel/call_center/model"
"github.com/webitel/protos/cc"
)

type agent struct {
app *app.App
cc.UnsafeAgentServiceServer
grpc.UnsafeAgentServiceServer
}

func NewAgentApi(a *app.App) *agent {
Expand Down
6 changes: 3 additions & 3 deletions grpc_api/api.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package grpc_api

import (
gogrpc "buf.build/gen/go/webitel/cc/grpc/go/_gogrpc"
"github.com/webitel/call_center/app"
"github.com/webitel/protos/cc"
"google.golang.org/grpc"
)

Expand All @@ -20,6 +20,6 @@ func Init(a *app.App, server *grpc.Server) {
api.agent = NewAgentApi(a)
api.member = NewMemberApi(a)

cc.RegisterAgentServiceServer(server, api.agent)
cc.RegisterMemberServiceServer(server, api.member)
gogrpc.RegisterAgentServiceServer(server, api.agent)
gogrpc.RegisterMemberServiceServer(server, api.member)
}
2 changes: 1 addition & 1 deletion grpc_api/client/agent.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package client

import (
cc "buf.build/gen/go/webitel/cc/protocolbuffers/go"
"context"
"github.com/webitel/protos/cc"
)

type agentApi struct {
Expand Down
11 changes: 6 additions & 5 deletions grpc_api/client/client.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package client

import (
grpc "buf.build/gen/go/webitel/cc/grpc/go/_gogrpc"
cc "buf.build/gen/go/webitel/cc/protocolbuffers/go"
"context"
"fmt"
"github.com/webitel/call_center/model"
"github.com/webitel/engine/discovery"
"github.com/webitel/protos/cc"
"github.com/webitel/wlog"
"sync"
)
Expand All @@ -30,10 +31,10 @@ type MemberApi interface {
AttemptResult(result *cc.AttemptResultRequest) error
RenewalResult(domainId, attemptId int64, renewal uint32) error

JoinCallToQueue(ctx context.Context, in *cc.CallJoinToQueueRequest) (cc.MemberService_CallJoinToQueueClient, error)
JoinChatToQueue(ctx context.Context, in *cc.ChatJoinToQueueRequest) (cc.MemberService_ChatJoinToQueueClient, error)
CallJoinToAgent(ctx context.Context, in *cc.CallJoinToAgentRequest) (cc.MemberService_CallJoinToAgentClient, error)
TaskJoinToAgent(ctx context.Context, in *cc.TaskJoinToAgentRequest) (cc.MemberService_TaskJoinToAgentClient, error)
JoinCallToQueue(ctx context.Context, in *cc.CallJoinToQueueRequest) (grpc.MemberService_CallJoinToQueueClient, error)
JoinChatToQueue(ctx context.Context, in *cc.ChatJoinToQueueRequest) (grpc.MemberService_ChatJoinToQueueClient, error)
CallJoinToAgent(ctx context.Context, in *cc.CallJoinToAgentRequest) (grpc.MemberService_CallJoinToAgentClient, error)
TaskJoinToAgent(ctx context.Context, in *cc.TaskJoinToAgentRequest) (grpc.MemberService_TaskJoinToAgentClient, error)

DirectAgentToMember(domainId int64, memberId int64, communicationId int, agentId int64) (int64, error)
CancelAgentDistribute(ctx context.Context, in *cc.CancelAgentDistributeRequest) (*cc.CancelAgentDistributeResponse, error)
Expand Down
14 changes: 7 additions & 7 deletions grpc_api/client/connection.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package client

import (
proto "github.com/webitel/protos/cc"
gogrpc "buf.build/gen/go/webitel/cc/grpc/go/_gogrpc"
"google.golang.org/grpc"
"google.golang.org/grpc/connectivity"
"time"
Expand All @@ -11,8 +11,8 @@ type ccConnection struct {
name string
host string
client *grpc.ClientConn
agent proto.AgentServiceClient
member proto.MemberServiceClient
agent gogrpc.AgentServiceClient
member gogrpc.MemberServiceClient
}

func NewCCConnection(name, url string) (*ccConnection, error) {
Expand All @@ -28,8 +28,8 @@ func NewCCConnection(name, url string) (*ccConnection, error) {
return nil, err
}

connection.agent = proto.NewAgentServiceClient(connection.client)
connection.member = proto.NewMemberServiceClient(connection.client)
connection.agent = gogrpc.NewAgentServiceClient(connection.client)
connection.member = gogrpc.NewMemberServiceClient(connection.client)

return connection, nil
}
Expand All @@ -54,10 +54,10 @@ func (conn *ccConnection) Close() error {
return nil
}

func (conn *ccConnection) Agent() proto.AgentServiceClient {
func (conn *ccConnection) Agent() gogrpc.AgentServiceClient {
return conn.agent
}

func (conn *ccConnection) Member() proto.MemberServiceClient {
func (conn *ccConnection) Member() gogrpc.MemberServiceClient {
return conn.member
}
11 changes: 6 additions & 5 deletions grpc_api/client/member.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package client

import (
gogrpc "buf.build/gen/go/webitel/cc/grpc/go/_gogrpc"
proto "buf.build/gen/go/webitel/cc/protocolbuffers/go"
"context"
proto "github.com/webitel/protos/cc"
)

type memberApi struct {
Expand All @@ -15,7 +16,7 @@ func NewMemberApi(m *ccManager) MemberApi {
}
}

func (api *memberApi) JoinCallToQueue(ctx context.Context, in *proto.CallJoinToQueueRequest) (proto.MemberService_CallJoinToQueueClient, error) {
func (api *memberApi) JoinCallToQueue(ctx context.Context, in *proto.CallJoinToQueueRequest) (gogrpc.MemberService_CallJoinToQueueClient, error) {
cli, err := api.cli.getRandomClient()
if err != nil {
return nil, err
Expand All @@ -24,7 +25,7 @@ func (api *memberApi) JoinCallToQueue(ctx context.Context, in *proto.CallJoinToQ
return cli.member.CallJoinToQueue(ctx, in)
}

func (api *memberApi) JoinChatToQueue(ctx context.Context, in *proto.ChatJoinToQueueRequest) (proto.MemberService_ChatJoinToQueueClient, error) {
func (api *memberApi) JoinChatToQueue(ctx context.Context, in *proto.ChatJoinToQueueRequest) (gogrpc.MemberService_ChatJoinToQueueClient, error) {
cli, err := api.cli.getRandomClient()
if err != nil {
return nil, err
Expand Down Expand Up @@ -82,7 +83,7 @@ func (api *memberApi) RenewalResult(domainId, attemptId int64, renewal uint32) e
return err
}

func (api *memberApi) CallJoinToAgent(ctx context.Context, in *proto.CallJoinToAgentRequest) (proto.MemberService_CallJoinToAgentClient, error) {
func (api *memberApi) CallJoinToAgent(ctx context.Context, in *proto.CallJoinToAgentRequest) (gogrpc.MemberService_CallJoinToAgentClient, error) {
cli, err := api.cli.getRandomClient()
if err != nil {
return nil, err
Expand All @@ -91,7 +92,7 @@ func (api *memberApi) CallJoinToAgent(ctx context.Context, in *proto.CallJoinToA
return cli.member.CallJoinToAgent(ctx, in)
}

func (api *memberApi) TaskJoinToAgent(ctx context.Context, in *proto.TaskJoinToAgentRequest) (proto.MemberService_TaskJoinToAgentClient, error) {
func (api *memberApi) TaskJoinToAgent(ctx context.Context, in *proto.TaskJoinToAgentRequest) (gogrpc.MemberService_TaskJoinToAgentClient, error) {
cli, err := api.cli.getRandomClient()
if err != nil {
return nil, err
Expand Down
13 changes: 7 additions & 6 deletions grpc_api/member.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package grpc_api

import (
grpc "buf.build/gen/go/webitel/cc/grpc/go/_gogrpc"
cc "buf.build/gen/go/webitel/cc/protocolbuffers/go"
"context"
"errors"
"fmt"
"github.com/webitel/call_center/app"
"github.com/webitel/call_center/model"
"github.com/webitel/call_center/queue"
"github.com/webitel/protos/cc"
)

type member struct {
app *app.App
cc.UnsafeMemberServiceServer
grpc.UnsafeMemberServiceServer
}

func NewMemberApi(a *app.App) *member {
Expand Down Expand Up @@ -110,7 +111,7 @@ func (api *member) AttemptResult(_ context.Context, in *cc.AttemptResultRequest)
}, nil
}

func (api *member) CallJoinToQueue(in *cc.CallJoinToQueueRequest, out cc.MemberService_CallJoinToQueueServer) error {
func (api *member) CallJoinToQueue(in *cc.CallJoinToQueueRequest, out grpc.MemberService_CallJoinToQueueServer) error {

ctx := out.Context()
attempt, err := api.app.Queue().Manager().DistributeCall(ctx, in)
Expand Down Expand Up @@ -186,7 +187,7 @@ stop:
return nil
}

func (api *member) ChatJoinToQueue(in *cc.ChatJoinToQueueRequest, out cc.MemberService_ChatJoinToQueueServer) error {
func (api *member) ChatJoinToQueue(in *cc.ChatJoinToQueueRequest, out grpc.MemberService_ChatJoinToQueueServer) error {
ctx := out.Context()
attempt, err := api.app.Queue().Manager().DistributeChatToQueue(ctx, in)
if err != nil {
Expand Down Expand Up @@ -302,7 +303,7 @@ func (api *member) AttemptRenewalResult(_ context.Context, in *cc.AttemptRenewal
return &cc.AttemptRenewalResultResponse{}, nil
}

func (api *member) CallJoinToAgent(in *cc.CallJoinToAgentRequest, out cc.MemberService_CallJoinToAgentServer) error {
func (api *member) CallJoinToAgent(in *cc.CallJoinToAgentRequest, out grpc.MemberService_CallJoinToAgentServer) error {
ctx := context.Background()
attempt, err := api.app.Queue().Manager().DistributeCallToAgent(ctx, in)
if err != nil {
Expand Down Expand Up @@ -355,7 +356,7 @@ stop:
return nil
}

func (api *member) TaskJoinToAgent(in *cc.TaskJoinToAgentRequest, out cc.MemberService_TaskJoinToAgentServer) error {
func (api *member) TaskJoinToAgent(in *cc.TaskJoinToAgentRequest, out grpc.MemberService_TaskJoinToAgentServer) error {
ctx := context.Background()
attempt, err := api.app.Queue().Manager().DistributeTaskToAgent(ctx, in)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion queue/expired.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package queue

import (
workflow "buf.build/gen/go/webitel/workflow/protocolbuffers/go"
"fmt"
"github.com/webitel/call_center/model"
"github.com/webitel/call_center/store"
"github.com/webitel/call_center/utils"
"github.com/webitel/protos/workflow"
"github.com/webitel/wlog"
"sync"
"time"
Expand Down
2 changes: 1 addition & 1 deletion queue/hook.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package queue

import (
workflow "buf.build/gen/go/webitel/workflow/protocolbuffers/go"
"fmt"
"github.com/webitel/call_center/model"
"github.com/webitel/protos/workflow"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion queue/queue_manager.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package queue

import (
cc "buf.build/gen/go/webitel/cc/protocolbuffers/go"
"context"
"encoding/json"
"fmt"
Expand All @@ -11,7 +12,6 @@ import (
"github.com/webitel/call_center/mq"
"github.com/webitel/call_center/store"
"github.com/webitel/call_center/utils"
"github.com/webitel/protos/cc"
"github.com/webitel/wlog"
"golang.org/x/sync/singleflight"
"net/http"
Expand Down
2 changes: 1 addition & 1 deletion queue/schema.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package queue

import (
flow "buf.build/gen/go/webitel/workflow/protocolbuffers/go"
"errors"
"fmt"
"github.com/webitel/call_center/model"
flow "github.com/webitel/protos/workflow"
"github.com/webitel/wlog"
"golang.org/x/sync/singleflight"
"time"
Expand Down
Loading

0 comments on commit d1463ef

Please sign in to comment.