vanus icon indicating copy to clipboard operation
vanus copied to clipboard

[Good First Issues]: implement function "split_from_end" - 7 points

Open Michaelg22 opened this issue 1 year ago • 5 comments

Motivation

Vanus Functions are a series of pre-built functions worked within Vanus transformer. By choosing a function, users can specify the way that events will be changed.

It will be a good start if you decide to contribute to Vanus codes.

Details

Function name: split_from_end

Args

  • sourceJsonPath
  • position
  • targetJsonPath

Description

The function is used to scan the source JSON path from right to left, split it into an array of two sub-strings from the given numeric position of the character, and assign the array to a target JSON path. The character of the position should be included in the first sub-string (from right to left).

Example

{
    "specversion" : "1.0",
    "type" : "com.example.someevent",
    "source" : "/mycontext",
    "subject": null,
    "id" : "C234-1234-1234",
    "time" : "2018-04-05T17:31:00Z",
    "comexampleextension1" : "value",
    "comexampleothervalue" : 5,
    "datacontenttype" : "application/json",
    "data": {
        "appinfoA" : "hello world!"
       

    }
}

After the function.

"pipeline":[
    {"command":["split_from_end", "$.data.appinfoA", 5, "$.data. appinfoB"]}
]

The transformed event should look like this:

{
    "specversion" : "1.0",
    "type" : "com.example.someevent",
    "source" : "/mycontext",
    "subject": null,
    "id" : "C234-1234-1234",
    "time" : "2018-04-05T17:31:00Z",
    "comexampleextension1" : "value",
    "comexampleothervalue" : 5,
    "datacontenttype" : "application/json",
    "data" : {
        "appinfoA" : "hello world!",
         "appinfoB" : ["hello w", "orld!"]
   }
}

How to implement

  1. Fork the vanus repository.
  2. Create a branch function-split_from_end
  3. Create split_from_end.go under internal/primitive/transform/action/strings, and then implement the function.
  4. Create split_from_end_test.go under internal/primitive/transform/action/strings for unit test.
  5. Register your function in internal/primitive/transform/runtime/init.go.
  6. Submit your PR

Contribution points

Each issue counts specific points based on its difficulty. Contributors earn the corresponding points if they solve that issue. Contribution points are used to describe the contributions contributors have made. They can also be used to get rewards when there are community events.

This issue counts 7 points.

How to claim to solve the issue

If you want to implement this function, please leave a comment in this issue like:

I'd like to implement this function, please assign this issue to me.

Vanus community will assign the issue to you on time.

Michaelg22 avatar Apr 03 '23 09:04 Michaelg22

Team, let me know if I can be of help for this one. I did split from start.

allensuvorov avatar Apr 14 '23 11:04 allensuvorov

I'd like to implement this function, please assign this issue to me.

ShadowWalker98 avatar Apr 14 '23 12:04 ShadowWalker98

Hi @ShadowWalker98 thank you for your interest, I assigned it to you

Michaelg22 avatar Jul 24 '23 00:07 Michaelg22

Hello, Any progress with this issue since April?

arsenalzp avatar Nov 15 '23 08:11 arsenalzp

Hi I’m really sorry. I was not able to do it yet. I actually joined for my masters degree, and was caught up in it, but I’ll get right on it by Dec 12th as my semester ends on that day.

On Wed, 15 Nov 2023 at 03:01, Oleksandr Krutko @.***> wrote:

Hello, Any progress with this issue since April?

— Reply to this email directly, view it on GitHub https://github.com/vanus-labs/vanus/issues/588#issuecomment-1811972499, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKTXGMTLVN47GWFHC2D6XRTYERZELAVCNFSM6AAAAAAWRBRA6WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJRHE3TENBZHE . You are receiving this because you were mentioned.Message ID: @.***>

ShadowWalker98 avatar Dec 07 '23 17:12 ShadowWalker98