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

#fix : update patch.go to call PatchValue correctly #397

Open
wants to merge 2 commits into
base: _dev
Choose a base branch
from

Conversation

the-nurk
Copy link

issue

PatchValue accepts (patch, val, ...), but was receiving (val, patch).

this is predicated on orig being the data getting patched, and patch being the patch plan, (as if generated by diff).

test

exec hof flow patch.cue
cmp stdout stdout.golden

-- stdout.golden --
P.next: {
    b: "b"
    e: {
            a: "a"
            b: "b"
            c: "c"
    }
    f: "new"
}

-- patch.cue --
package patch

// original thing being patched
o: {
    a: "a"
    b: "b"
    e: {
        a: "a"
        b: "b"
        d: "d"
    }
}

// update structure
p: {
    "-": {
        a: "a"    // remove field 'a'
    }
    e: {
        "-": {
            d: "d"    // remove nested field 'd'
        }
        "+": {
            c: "c"    // add new nested field 'c'
        }
    }
    "+": {
        f: "new"     // add new field 'f'
    }
}

@flow()
P: {
  @task(st.Patch)
  orig: o
  patch: p
  next: _
} @print(next)

// Result after patch
n: {
    b: "b"
    e: {
        a: "a"
        b: "b"
        c: "c"
    }
    f: "new"
}
// validation
n: P.next

PatchValue accepts (patch, val, ...), but was receiving (val, patch). 

this is predicated on `orig` being the data getting patched, and `patch` being the patch plan, (as if generated by diff).
wrapped in golang stdlib context and moved to channel event handler pattern to hopefully submit a better base for this module.

two process management channels for watching completeness and error via wait groups.

unsure if `ret` defaults are what we want, but put them in there for succinctness.

single config extraction function instead of ferr
@verdverm
Copy link
Member

verdverm commented Dec 2, 2024

What's with the exec refactor?

Not opposed, can you add a bit about what those changes are for or improve?


ferr := func() error {
Copy link
Author

@the-nurk the-nurk Dec 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't like this style tbh. i'm more of a clear, linear, conditional function dispatch kinda guy. despite some of my code sometimes not looking like that.

}

// fill exit code / successful
Copy link
Author

@the-nurk the-nurk Dec 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm like 99% sure this use of ProcessState before checking if it was available was causing a segmentation fault for me. i'm kinda passed it so i forgot the reproduction. i was moving fast so i just re-wrote it with some ai help in all honesty. i've read a decent amount of the codebase and had to hand stitch this together since claude didn't exactly do well. it mainly just helped with what i would imagine a cookie cutter implementation for a nice threaded approach might look like with room for tracking multiple channels. i'm no goru but it works so far :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i can put it on my list to reproduce, but it might be a couple hundred thousand minutes.

Copy link
Author

@the-nurk the-nurk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i show probably review the things i submit and provide more context. @verdverm

return ret, nil
}

func extractExecConfig(v cue.Value) (
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"clean, linear, function dispatch"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants