mirror of
https://github.com/absmach/magistrala.git
synced 2026-08-07 07:14:46 +00:00
SMQ - 2546 - Add telemetry aggregation for clients telemetry (#2661)
Signed-off-by: Felix Gateru <felix.gateru@gmail.com>
This commit is contained in:
+24
-1
@@ -140,13 +140,21 @@ func (page JournalsPage) MarshalJSON() ([]byte, error) {
|
||||
type ClientTelemetry struct {
|
||||
ClientID string `json:"client_id"`
|
||||
DomainID string `json:"domain_id"`
|
||||
Subscriptions []string `json:"subscriptions"`
|
||||
Subscriptions uint64 `json:"subscriptions"`
|
||||
InboundMessages uint64 `json:"inbound_messages"`
|
||||
OutboundMessages uint64 `json:"outbound_messages"`
|
||||
FirstSeen time.Time `json:"first_seen"`
|
||||
LastSeen time.Time `json:"last_seen"`
|
||||
}
|
||||
|
||||
type ClientSubscription struct {
|
||||
ID string `json:"id" db:"id"`
|
||||
SubscriberID string `json:"subscriber_id" db:"subscriber_id"`
|
||||
ChannelID string `json:"channel_id" db:"channel_id"`
|
||||
Subtopic string `json:"subtopic" db:"subtopic"`
|
||||
ClientID string `json:"client_id" db:"client_id"`
|
||||
}
|
||||
|
||||
// Service provides access to the journal log service.
|
||||
//
|
||||
//go:generate mockery --name Service --output=./mocks --filename service.go --quiet --note "Copyright (c) Abstract Machines"
|
||||
@@ -179,4 +187,19 @@ type Repository interface {
|
||||
|
||||
// DeleteClientTelemetry removes telemetry data for a client from the database.
|
||||
DeleteClientTelemetry(ctx context.Context, clientID, domainID string) error
|
||||
|
||||
// AddSubscription adds a subscription to the client telemetry.
|
||||
AddSubscription(ctx context.Context, sub ClientSubscription) error
|
||||
|
||||
// CountSubscriptions returns the number of subscriptions for a client.
|
||||
CountSubscriptions(ctx context.Context, clientID string) (uint64, error)
|
||||
|
||||
// RemoveSubscription removes a subscription from the client telemetry.
|
||||
RemoveSubscription(ctx context.Context, subscriberID string) error
|
||||
|
||||
// IncrementInboundMessages increments the inbound messages count for a client.
|
||||
IncrementInboundMessages(ctx context.Context, clientID string) error
|
||||
|
||||
// IncrementOutboundMessages increments the outbound messages count for a client.
|
||||
IncrementOutboundMessages(ctx context.Context, channelID, subtopic string) error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user