-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: ingestion processing cleanup (#209)
Co-authored-by: Michal Fiedorowicz <[email protected]>
- Loading branch information
1 parent
99c7000
commit 252498e
Showing
12 changed files
with
272 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package postgres | ||
|
||
import ( | ||
"fmt" | ||
|
||
"google.golang.org/protobuf/encoding/protojson" | ||
|
||
"github.com/netboxlabs/diode/diode-server/gen/diode/v1/diodepb" | ||
"github.com/netboxlabs/diode/diode-server/gen/diode/v1/reconcilerpb" | ||
) | ||
|
||
// ToProto converts sqlc structure to analogous protobuf | ||
func (log IngestionLog) ToProto() (*reconcilerpb.IngestionLog, error) { | ||
entity := &diodepb.Entity{} | ||
if err := protojson.Unmarshal(log.Entity, entity); err != nil { | ||
return nil, fmt.Errorf("failed to unmarshal entity: %w", err) | ||
} | ||
var ingestionErr reconcilerpb.IngestionError | ||
if log.Error != nil { | ||
if err := protojson.Unmarshal(log.Error, &ingestionErr); err != nil { | ||
return nil, fmt.Errorf("failed to unmarshal error: %w", err) | ||
} | ||
} | ||
|
||
pblog := &reconcilerpb.IngestionLog{ | ||
Id: log.ExternalID, | ||
DataType: log.DataType.String, | ||
State: reconcilerpb.State(log.State.Int32), | ||
RequestId: log.RequestID.String, | ||
IngestionTs: log.IngestionTs.Int64, | ||
ProducerAppName: log.ProducerAppName.String, | ||
ProducerAppVersion: log.ProducerAppVersion.String, | ||
SdkName: log.SdkName.String, | ||
SdkVersion: log.SdkVersion.String, | ||
Entity: entity, | ||
Error: &ingestionErr, | ||
} | ||
|
||
return pblog, nil | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.