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

Publish system events on space prefixed path for hosted version #485

Merged
merged 7 commits into from
Jul 24, 2018

Conversation

mthenw
Copy link
Contributor

@mthenw mthenw commented Jul 24, 2018

Todos:

  • Write tests
  • Write documentation
  • Fix linting errors
  • Make sure code coverage hasn't dropped
  • Provide verification commands / resources
  • Enable "Allow edits from maintainers" for this PR
  • Update the messages below

Is this ready for review?: Yes
Is it a breaking change?: NO

@mthenw mthenw requested a review from sebito91 July 24, 2018 08:02
@codecov
Copy link

codecov bot commented Jul 24, 2018

Codecov Report

Merging #485 into master will decrease coverage by 0.01%.
The diff coverage is 83.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #485      +/-   ##
==========================================
- Coverage   70.78%   70.77%   -0.02%     
==========================================
  Files          35       37       +2     
  Lines        2184     2190       +6     
==========================================
+ Hits         1546     1550       +4     
- Misses        574      576       +2     
  Partials       64       64
Impacted Files Coverage Δ
router/path.go 100% <100%> (ø)
router/path_hosted.go 71.42% <71.42%> (ø)
router/router.go 64.1% <80%> (-0.79%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8babc3c...5770b28. Read the comment docs.

Copy link
Contributor

@sebito91 sebito91 left a comment

Choose a reason for hiding this comment

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

A couple of nits but overall seems fine by me. Nicely done!


// systemPathFromPath constructs path from path on which event was emitted. Helpful for "event.received" system event.
func systemPathFromPath(path string) string {
return "/" + strings.Split(path, "/")[1] + "/"
Copy link
Contributor

Choose a reason for hiding this comment

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

We guarantee here somehow that path would never be / only, correct? Otherwise this will blow up during subindexing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this code is only compiled for hosted EG. We guarantee that the first segment of path is always space name. Also if that assumption is wrong it's actually better to blow up asap :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Love it!

router/path.go Outdated
}

func systemPathFromPath(space string) string {
return "/"
Copy link
Contributor

Choose a reason for hiding this comment

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

Make / into a keyword somewhere in router package, something like BASEPATH? We do use it a lot throughout.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, sure I can do that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you think that this should be used only in this file or also in path_hosted.go?

Copy link
Contributor

Choose a reason for hiding this comment

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

You can make the global const available package-wide and just user wherever you need!

@@ -458,7 +454,7 @@ func (router *Router) emitSystemEventReceived(path string, event eventpkg.Event,
mimeJSON,
eventpkg.SystemEventReceivedData{Path: path, Event: event, Headers: ihttp.FlattenHeader(header)},
)
router.handleAsyncSubscriptions(http.MethodPost, "/", *system, nil)
router.handleAsyncSubscriptions(http.MethodPost, systemPathFromPath(path), *system, nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this would be more idiomatic to use something like BASEPATH instead of the helper function call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason for helper function is that systemPathFromPath is compiled differently depending on build tag. That's the reason for having two implementations for those three functions

Copy link
Contributor

Choose a reason for hiding this comment

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

Understood, that makes a lot of sense


# include coverage for hosted EG
go test -race -coverprofile=profile.out -covermode=atomic -tags=hosted ./router
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we put the coverprofile straight to coverage.txt?

Copy link
Contributor

@sebito91 sebito91 left a comment

Choose a reason for hiding this comment

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

Last nit!

codecov.sh Outdated

# include coverage for hosted EG
go test -race -coverprofile=profile.out -covermode=atomic -tags=hosted ./router >> coverage.txt
Copy link
Contributor

Choose a reason for hiding this comment

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

What I was saying was more like...

go test --reace --coverprofile=coverage.txt --covermode=atomic --tags=hosted ./router

@mthenw mthenw merged commit 8e58739 into master Jul 24, 2018
@mthenw mthenw deleted the fix-hosted-system-path branch July 24, 2018 14:37
@sebito91 sebito91 mentioned this pull request Jul 24, 2018
7 tasks
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.

None yet

2 participants