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

Added controller action generator for create, new, edit, update, delete #195

Closed
wants to merge 2 commits into from

Conversation

dangerzone
Copy link

Addresses issue #55 since #75 has become stale.

In addition to the changes made by @fergloragain, this PR fixes some errors present in that PR and adds views for edit and new actions. It also makes the action creation error more helpful.

The views aren't terribly pretty though since I'm not one with the CSS.

@CLAassistant
Copy link

CLAassistant commented Jul 7, 2022

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@matthewmueller matthewmueller left a comment

Choose a reason for hiding this comment

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

Thanks so much for for working on #75 @dangerzone!

I pulled it down and tried:

bud new controller posts new show index create delete update edit

But ran into this concurrency error:

fatal error: concurrent map iteration and map write

The problem is the vfs.Memory in the scaffolder isn't concurrency-safe:

eg.Go(func() error { return s.Scaffold(fsys) })
}

I was thinking about swapping that out for https://github.com/psanford/memfs, but it'd also need to implement the RemoveAll function. Maybe a fork? We could also keep it simpler and just wrap the functions in mutexes. Adjusting the internal vfs.Memory API will be necessary.

Feel free to take a stab at fixing this, otherwise I'll get that fixed over the weekend.

@@ -170,13 +219,15 @@ func (c *Command) views(controller *Controller) (views []*View) {
}

func (c *Command) view(controller *Controller, action *Action) *View {
fmt.Println(action.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove fmt

Copy link
Author

Choose a reason for hiding this comment

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

If we wrap it in a mutex, that'd defeat the purpose of having it be in a goroutine. For now, I say we run the scaffolding sequentially instead of concurrently. This isn't exactly a performance critical hot-path anyway and there are lower hanging fruit for us to occupy our time with ;)

Copy link
Author

Choose a reason for hiding this comment

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

I removed the concurrent calls and it works as expected

@matthewmueller
Copy link
Contributor

matthewmueller commented Jul 14, 2022

Thanks for your effort on this one @dangerzone! I ended up creating a new PR because there were quite a few changes I wanted to make and tests to add.

I based a lot of the initial work on this PR, so I really appreciate your help with that and also giving me the extra oomf to wrap this up!

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.

3 participants