vanus-labs / vanus

Vanus is a Serverless, event streaming system with processing capabilities. It easily connects SaaS, Cloud Services, and Databases to help users build next-gen Event-driven Applications.
https://vanus.ai
Apache License 2.0
2.29k stars 113 forks source link

[Good First Issues]: implement function "today" - 4 points #462

Open Michaelg22 opened 1 year ago

Michaelg22 commented 1 year ago

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: today

Args

Description

The function is used to get the current date(format: YYYY-MM-DD) in a specific TimeZone. And assign it to the target JSON path. The Time Zone will be UTC if users don't specify it.

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":["today","$.data.time", "Europe/Madrid"]}
]

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",
        time : "2023-01-12"

How to implement

  1. Fork the vanus repository.
  2. Create a branch function-today
  3. Create today.go under internal/primitive/transform/action/datatime, and then implement the function.
  4. Create today.go under internal/primitive/transform/action/datatime 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 4 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 commented 1 year ago

Looking for a new person to contribute to this issue. :)

kbavi commented 1 year ago

@Michaelg22 hey, I would like to work on this issue.

Michaelg22 commented 1 year ago

Thanks I will assign it to you!

xdlbdy commented 1 year ago

the time format is Y-m-d

Michaelg22 commented 1 year ago

Should we add an argument to change it @xdlbdy

Michaelg22 commented 1 year ago

y-m-d or d-m-y and m-d-y ...

kbavi commented 1 year ago

targetJsonPath - The name of an existing column

The provided example {"command":["today","$.data.time", "Europe/Madrid"]} works on the event where the data map does not have a time column as suggested by $.data.time. @Michaelg22 can you please clarify the requirement or help me understand if I am missing something.

xdlbdy commented 1 year ago

I have changed the description of targetJSONPath

c0d33ngr commented 1 year ago

Please I'd love to work on this

shashank-mishra14 commented 1 year ago

Hey, Please assign this issue to me, I want to work on this too.

amribm commented 1 year ago

hey, please assign it to me. i will love to work on this.

Michaelg22 commented 1 year ago

hi @AmeerIbrahimm I assign it to you.