Skip to content

Commit

Permalink
Enable consumers with no transformer
Browse files Browse the repository at this point in the history
Signed-off-by: Dusan Borovcanin <borovcanindusan1@gmail.com>
  • Loading branch information
dborovcanin committed Dec 27, 2024
1 parent 0045057 commit d05dc53
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 17 deletions.
6 changes: 1 addition & 5 deletions consumers/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,7 @@ func loadConfig(configPath string) (config, error) {
SubscriberCfg: subscriberConfig{
Subjects: []string{brokers.SubjectAllChannels},
},
TransformerCfg: transformerConfig{
Format: defFormat,
ContentType: defContentType,
},
TransformerCfg: transformerConfig{},
}

data, err := os.ReadFile(configPath)
Expand All @@ -153,7 +150,6 @@ func makeTransformer(cfg transformerConfig, logger *slog.Logger) transformers.Tr
return json.New(cfg.TimeFields)
default:
logger.Error(fmt.Sprintf("Can't create transformer: unknown transformer type %s", cfg.Format))
os.Exit(1)
return nil
}
}
2 changes: 1 addition & 1 deletion re/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
// SPDX-License-Identifier: Apache-2.0

// Package writers contain the domain concept definitions needed to
// support Magistrala writer services functionality.
// support Magistrala Rule Egine services functionality.
package re
3 changes: 3 additions & 0 deletions re/postgres/repository.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Abstract Machines
// SPDX-License-Identifier: Apache-2.0

package postgres

import (
Expand Down
5 changes: 3 additions & 2 deletions re/service.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Abstract Machines
// SPDX-License-Identifier: Apache-2.0

package re

import (
Expand Down Expand Up @@ -35,8 +38,6 @@ type Schedule struct {
RecurringPeriod uint // 1 meaning every Recurring value, 2 meaning every other, and so on.
}

// Status represents Rule status.

type Rule struct {
ID string `json:"id"`
DomainID string `json:"domain"`
Expand Down
15 changes: 6 additions & 9 deletions re/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ import (
svcerr "github.com/absmach/magistrala/pkg/errors/service"
)

// Status represents User status.
// Status represents Rule status.
type Status uint8

// Possible User status values.
const (
// EnabledStatus represents enabled User.
// EnabledStatus represents enabled Rule.
EnabledStatus Status = iota
// DisabledStatus represents disabled User.
// DisabledStatus represents disabled Rule.
DisabledStatus
// DeletedStatus represents a user that will be deleted.
// DeletedStatus represents a rule that will be deleted.
DeletedStatus

// AllStatus is used for querying purposes to list users irrespective
// AllStatus is used for querying purposes to list rules irrespective
// of their status - both enabled and disabled. It is never stored in the
// database as the actual User status and should always be the largest
// value in this enumeration.
Expand All @@ -38,7 +38,6 @@ const (
Unknown = "unknown"
)

// String converts user/group status to string literal.
func (s Status) String() string {
switch s {
case DisabledStatus:
Expand All @@ -54,7 +53,7 @@ func (s Status) String() string {
}
}

// ToStatus converts string value to a valid User/Group status.
// ToStatus converts string value to a valid status.
func ToStatus(status string) (Status, error) {
switch status {
case "", Enabled:
Expand All @@ -69,12 +68,10 @@ func ToStatus(status string) (Status, error) {
return Status(0), svcerr.ErrInvalidStatus
}

// Custom Marshaller for Uesr/Groups.
func (s Status) MarshalJSON() ([]byte, error) {
return json.Marshal(s.String())
}

// Custom Unmarshaler for User/Groups.
func (s *Status) UnmarshalJSON(data []byte) error {
str := strings.Trim(string(data), "\"")
val, err := ToStatus(str)
Expand Down

0 comments on commit d05dc53

Please sign in to comment.