Skip to content

Logline specialization#63

Merged
arl merged 7 commits intomainfrom
logline-specialization
Oct 27, 2020
Merged

Logline specialization#63
arl merged 7 commits intomainfrom
logline-specialization

Conversation

@arl
Copy link
Copy Markdown
Collaborator

@arl arl commented Oct 26, 2020

❓ What

Make baker.LogLine more easily customizable.
LogLine hardcoded constants are now only used in logline.go so that if one copies that file to their project all continues to work.
Document how to do it in README.md

Describe what this pull request does.

🔨 How to test

  1. List all steps necessary;
  2. To test this pull request.

✅ Checklists

This section contains a list of checklists for common uses, please delete the checklists that are useless for your current use case (or add another checklist if your use case isn't covered yet).

  • Is there unit/integration test coverage for all new and/or changed functionality added in this PR?
  • Have the changes in this PR been functionally tested?
  • Has make gofmt-write been run on the code?
  • Has make govet been run on the code? Has the code been fixed accordingly to the output?
  • Have the changes been added to the CHANGELOG.md file?
  • Have the steps in CONTRIBUTING.md been followed to update a Go module?

arl added 4 commits October 26, 2020 16:36
`Topology.invalid` was an array using the `LogLineNumFields` constant
and so was tightly coupled with the current definition of `LogLine`.

Convert it to a map protected with a RWMutex (previously the array
elements were atomically incremented).
@arl arl requested a review from tommyblue October 26, 2020 16:09
Copy link
Copy Markdown
Contributor

@tommyblue tommyblue left a comment

Choose a reason for hiding this comment

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

lgtm

Comment thread README.md Outdated
Comment thread README.md

If the hardcoded values for `LogLineNumFields` and `NumFieldsBaker` do not suit
your needs, it's advised that you copy `logline.go` in your project and modify
the constants declared at the top of the file. Your specialized `LogLine` will
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the user should copy the logline but also rename the object, if I'm not mistaken. If true, I'd also change the code example below using something like MyCustomLogline

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

No it's not necessary since the user will do this in its own project so in a different package so the definitions are never going to clash

Comment thread stats_test.go Outdated
Comment thread topology.go
if ok, idx := t.validate(record); !ok {
atomic.AddInt64(&t.invalid[idx], 1)
ok, idx := t.validate(record)
if !ok {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is it as fast as the previous version?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

No it's not since incrementing an atomic is faster than locking a mutex. However this is the only correct way to do it. Moreover the change is only seen when there's an invalid logline, the happy path stays the same

arl and others added 2 commits October 27, 2020 12:16
Co-authored-by: Tommaso Visconti <tommaso.visconti@adroll.com>
Co-authored-by: Tommaso Visconti <tommaso.visconti@adroll.com>
@arl arl merged commit b96aadb into main Oct 27, 2020
@arl arl deleted the logline-specialization branch October 27, 2020 11:42
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