Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Good First Issues]: implement function "now" - 4 points #430

Open
Tracked by #355
Michaelg22 opened this issue Feb 13, 2023 · 10 comments · May be fixed by #456
Open
Tracked by #355

[Good First Issues]: implement function "now" - 4 points #430

Michaelg22 opened this issue Feb 13, 2023 · 10 comments · May be fixed by #456
Assignees
Labels
good first issue help-wanted Extra attention is needed

Comments

@Michaelg22
Copy link
Contributor

Michaelg22 commented Feb 13, 2023

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

Args

  • targetJsonPath
  • timeZone Optional. The name of a time zone. If no time zone is specified, then the default is Universal Coordinated Time (UTC).

Description

The function is used to get the current time(format: yyyy-mm-dd hh:MM:SS) 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":["now","$.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 13:58:59"

How to implement

  1. Fork the vanus repository.
  2. Create a branch function-now
  3. Create now.go under internal/primitive/transform/action/datatime, and then implement the function.
  4. Create now.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 Michaelg22 added help-wanted Extra attention is needed good first issue labels Feb 13, 2023
@pradeepnnv
Copy link

I would like to try this out. Please assign it to me.

@thiyagarajan17
Copy link

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

@Michaelg22
Copy link
Contributor Author

Hi @pradeepnnv, Thank you for your interest in contributing to this function. I have assigned it to you. For better communication in the future join our Slack community

@Michaelg22
Copy link
Contributor Author

hi @thiyagarajan17, We would love to have you contribute to another function Issue.
The function called Today is similar to this function you can have a look 429

@Michaelg22
Copy link
Contributor Author

@pradeepnnv How is your progress?

@Michaelg22
Copy link
Contributor Author

Please make sure to move the function to internal/primitive/transform/action/datatime

@Michaelg22
Copy link
Contributor Author

Hello @pradeepnnv, I wanted to check in with you regarding the issue you expressed interest in writing a function for. I haven't heard from you in a while, so I was wondering if you're still interested in working on it. Please let me know if you are, otherwise, I will need to assign the task to someone else who is available and willing to work on it.

@pradeepnnv
Copy link

Hi @Michaelg22 , sorry for the delay in my response.

I'm currently working on this task. I do have a clarification though.

I created the now function as you instructed. But should I create an implementation in internal/primitive/transform/function/datatime_functions.go?

Please refer to the draft PR https://github.com/vanus-labs/vanus/pull/456/files#diff-edfabcf9030ccd0417dda452deaf96583455c624c09f075bc1ca8ff000210805.

@xdlbdy xdlbdy linked a pull request Feb 25, 2023 that will close this issue
4 tasks
@xdlbdy
Copy link
Contributor

xdlbdy commented Feb 25, 2023

The internal/primitive/transform/function package provides some util functions for you to implement the vanus function, but it is unnecessary, also you can create util functions for implementing the vanus now function.

@xdlbdy
Copy link
Contributor

xdlbdy commented Feb 25, 2023

I have reviewed pr #456, and it is no problem, pls add some ut case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue help-wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants