Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

send the resend all unacked message on socket as an array for ui #1176

Merged
merged 4 commits into from
Jul 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -2348,7 +2348,9 @@ func InsertNewProducer(name string, stationId int, producerType string, connecti
var producerId int
updatedAt := time.Now()
isActive := true
tenantName = strings.ToLower(tenantName)
if tenantName != conf.GlobalAccount {
tenantName = strings.ToLower(tenantName)
}
rows, err := conn.Conn().Query(ctx, stmt.Name, name, stationId, connectionIdObj, isActive, updatedAt, producerType, tenantName)
if err != nil {
return models.Producer{}, err
Expand Down
1 change: 1 addition & 0 deletions models/stations.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ type GetStationResponseSchema struct {
IsNative bool `json:"is_native"`
DlsConfiguration DlsConfiguration `json:"dls_configuration"`
TieredStorageEnabled bool `json:"tiered_storage_enabled"`
ResendDisabled bool `json:"resend_disabled"`
}

type ExtendedStation struct {
Expand Down
3 changes: 3 additions & 0 deletions server/memphis_handlers_monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@ func (mh MonitoringHandler) GetStationOverviewData(c *gin.Context) {
"total_dls_messages": totalDlsAmount,
"tiered_storage_enabled": station.TieredStorageEnabled,
"created_by_username": station.CreatedByUsername,
"resend_disabled": station.ResendDisabled,
}
} else {
var emptyResponse struct{}
Expand Down Expand Up @@ -694,6 +695,7 @@ func (mh MonitoringHandler) GetStationOverviewData(c *gin.Context) {
"total_dls_messages": totalDlsAmount,
"tiered_storage_enabled": station.TieredStorageEnabled,
"created_by_username": station.CreatedByUsername,
"resend_disabled": station.ResendDisabled,
}
} else {
response = gin.H{
Expand All @@ -719,6 +721,7 @@ func (mh MonitoringHandler) GetStationOverviewData(c *gin.Context) {
"total_dls_messages": totalDlsAmount,
"tiered_storage_enabled": station.TieredStorageEnabled,
"created_by_username": station.CreatedByUsername,
"resend_disabled": station.ResendDisabled,
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion server/memphis_handlers_stations.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ func (sh StationsHandler) GetStation(c *gin.Context) {
DlsConfiguration: models.DlsConfiguration{Poison: station.DlsConfigurationPoison, Schemaverse: station.DlsConfigurationSchemaverse},
TieredStorageEnabled: station.TieredStorageEnabled,
Tags: tags,
ResendDisabled: station.ResendDisabled,
}

c.IndentedJSON(200, stationResponse)
Expand Down Expand Up @@ -958,6 +959,7 @@ func (sh StationsHandler) CreateStation(c *gin.Context) {
"dls_configuration_poison": newStation.DlsConfigurationPoison,
"dls_configuration_schemaverse": newStation.DlsConfigurationSchemaverse,
"tiered_storage_enabled": newStation.TieredStorageEnabled,
"resend_disabled": newStation.ResendDisabled,
})
} else {
c.IndentedJSON(200, gin.H{
Expand All @@ -977,6 +979,7 @@ func (sh StationsHandler) CreateStation(c *gin.Context) {
"dls_configuration_poison": newStation.DlsConfigurationPoison,
"dls_configuration_schemaverse": newStation.DlsConfigurationSchemaverse,
"tiered_storage_enabled": newStation.TieredStorageEnabled,
"resend_disabled": newStation.ResendDisabled,
})
}
}
Expand Down Expand Up @@ -2263,7 +2266,7 @@ func (s *Server) ResendAllDlsMsgs(stationName string, stationId int, tenantName
}

systemMessage := SystemMessage{
MessageType: "Info",
MessageType: "info",
MessagePayload: fmt.Sprintf("Resend all unacked messages operation in station %s, triggered by user %s has been completed successfully", stationIdStr, username),
}

Expand Down
14 changes: 13 additions & 1 deletion server/memphis_handlers_ws.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"strconv"
"strings"
"time"

"github.com/gofrs/uuid"
)

const (
Expand Down Expand Up @@ -430,7 +432,17 @@ func (s *Server) sendSystemMessageOnWS(user models.User, systemMessage SystemMes
return err
}

updateRaw, err := json.Marshal(systemMessage)
if systemMessage.Id == "" {
uid, err := uuid.NewV4()
if err != nil {
err = fmt.Errorf("sendSystemMessageOnWS at uuid.NewV4: %v", err.Error())
return err
}
systemMessage.Id = uid.String()
}
systemMessages := []SystemMessage{}
systemMessages = append(systemMessages, systemMessage)
updateRaw, err := json.Marshal(systemMessages)
if err != nil {
err = fmt.Errorf("sendSystemMessageOnWS at json.Marshal: %v", err.Error())
return err
Expand Down