-
-
Notifications
You must be signed in to change notification settings - Fork 179
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
Conversation
There was a problem hiding this 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:
bud/internal/scaffold/scaffold.go
Lines 78 to 79 in de066c6
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove fmt
There was a problem hiding this comment.
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 ;)
There was a problem hiding this comment.
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
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! |
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.