Skip to content

eclipse-ecsp/transformers

Transformers

Build License Compliance Deployment

The transformers project provides serialization/deserialization support to the services. The following approaches are supported:

  1. Serialization/Deserialization support for an BlobEvent.
  2. Use of Fast Serialization library to implement FST based serialization/deserialization for ingestion data
  3. Below Transformers along with the capability of extending Transformer to create a new transformer for event
    • Device Message Transformer - serialization to byte[] from event
    • Generic Transformer - serialization/deserialization to/from byte[] to generic event along with event attributes validation
    • Event data key transformer - serialization/deserialization to/from byte[] to key
  4. Support for adding object based serializers, deserializers and subtypes to the Jackson module's ObjectMapper

Table of Contents

Getting Started

To build the project in the local working directory after the project has been cloned/forked, run:

mvn clean install

from the command line interface.

Prerequisites

  1. Maven
  2. Java 17

Installation

How to set up maven

Install Java

Running the tests

mvn test

Or run a specific test

mvn test -Dtest="TheFirstUnitTest"

To run a method from within a test

mvn test -Dtest="TheSecondUnitTest#whenTestCase2_thenPrintTest2_1"

Deployment

Transformers project serves as a library for the services. It is not meant to be deployed as a service in any cloud environment.

Usage

Add the following dependency in the target project

<dependency>
  <groupId>org.eclipse.ecsp</groupId>
  <artifactId>transformers</artifactId>
  <version>1.X.X</version>
</dependency>

Implementing a Transformer

A custom transformer can be created for an IgniteEvent type by extending the Transformer contract.

Example:

public class GenericIgniteEventTransformer implements Transformer {
    @Override
    public IgniteEvent fromBlob(byte[] value, Optional<IgniteEventBase> header) {
        // deserialization logic
    }

    @Override
    public byte[] toBlob(IgniteEvent value) {
        // serialization logic
    }
}

Custom serializers, deserializers and subtypes

Services can provide custom serializers, deserializers, and subtypes to the Jackson's object mapper from the environment properties specified by the following:

#comma separated value for custom deserializer. className and it's deserializer needs to separated by :
#Example: k1:v1,k2:v2
custom.deserializers=org.eclipse.ecsp.entities.EventData:org.eclipse.ecsp.entities.EventDataDeSerializer
#Custom serializer in the form of  k1:v1,k2:v2
custom.serializers=
#Custom subtypes in the form of k1:v1,k2:v2
custom.subtypes=

Implementing IgniteEvent attribute validation

The validation for a particular IgniteEvent attribute needs to be configured in the environment properties by the service.

NOTE: attribute name needs to be followed with 'inputValidation' prefix

Example:

EventID.inputvalidation=ALPHA
BizTransactionId.inputvalidation=ALPHA_NUMERIC
Timestamp.inputvalidation=NUMERIC|13
DFFQualifier.inputvalidation=ALPHA
CorrelationId.inputvalidation=NUMERIC
MessageId.inputvalidation=NUMERIC|6
RequestId.inputvalidation=ALPHA_NUMERIC|-
SourceDeviceId.inputvalidation=ALPHA_NUMERIC
VehicleId.inputvalidation=ALPHA_NUMERIC

Built With Dependencies

Dependency Purpose
Utils Logging Support
Spring Framework For writing tests
Maven Dependency Management
Junit Testing framework
Mockito Test Mocking framework
Power Mock Test Mocking framework with extra mocking features
Fast Serialization FST serialization support

How to contribute

Please read CONTRIBUTING.md for details on our contribution guidelines, and the process for submitting pull requests to us.

Code of Conduct

Please read CODE_OF_CONDUCT.md for details on our code of conduct.

Authors

Kaushal Arora
Kaushal Arora

πŸ“– πŸ‘€
Hussain Badshah
Hussain Badshah

πŸ“– πŸ‘€

See also the list of contributors who participated in this project.

Security Contact Information

Please read SECURITY.md to raise any security related issues.

Support

Please write to us at csp@harman.com

Troubleshooting

Please read CONTRIBUTING.md for details on how to raise an issue and submit a pull request to us.

License

This project is licensed under the Apache-2.0 License - see the LICENSE file for details.

Announcements

All updates to this library are documented in our Release notes and releases For the versions available, see the tags on this repository.

About

ECSP Transformers

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages