-
Notifications
You must be signed in to change notification settings - Fork 0
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
Log splicer rewrite #9
Conversation
d43e8aa
to
53495c6
Compare
cmd/log-splicer/main.go
Outdated
@@ -20,9 +26,12 @@ import ( | |||
"go.cryptoscope.co/margaret/legacyflumeoffset" | |||
) | |||
|
|||
// TODO: collapse feedinfo + feedjson into just feedinfo? and use temp struct for unmarshaling ID? |
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 decided not to do this: feels cleaner the way it is, and the two data structures have their own priorities. FeedInfo collects FeedInfo, FeedJSON is used to persist feed mappings to json. the last one could maybe have a better name, but hey life is short
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 the comment then :)
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.
some high-level/meta contents. Change looks very good overall!
cmd/log-splicer/main.go
Outdated
@@ -20,9 +26,12 @@ import ( | |||
"go.cryptoscope.co/margaret/legacyflumeoffset" | |||
) | |||
|
|||
// TODO: collapse feedinfo + feedjson into just feedinfo? and use temp struct for unmarshaling ID? |
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 the comment then :)
// * Maps identities to folder names they live in | ||
// * Copies secrets from the fixtures folder to each identity folder | ||
// * Splics out messages from the one ssb-fixtures log.offset to the many log.offset in said folder structure | ||
// * Persists an identity mapping of ID to {folderName, latest sequence number} to secret-ids.json |
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.
This is a meta comment about using markdown lists, which sadly fails horribly.
here are some options: https://stackoverflow.com/a/52745058
(ps: If you like, you could subscribe to golang/go#7873)
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 made a modified version of Godoc that adds ordered and unordered lists with a fast and simple custom parser I wrote called slippery-slope-markdown.
🤣
cmd/log-splicer/main.go
Outdated
|
||
_, err = a.log.Append(v) | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "failed to write entry to output log %s: %s\n", logPaths[1], err) | ||
fmt.Fprintf(os.Stderr, "failed to write entry to output log %s: %s\n", outdir, err) |
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.
meta comment: If this fmt.Fprint(os.Stderr, ...); os.Exit(1)
style becomes to repetetiv, you could try something like this here:
func spliceLogs() error {
// actual work with "normal" error handling
// ...
}
func main() {
// flags stuff
flag.Parse()
err:= sliceLogs()
if err!=nil {
fmt.Fprintf(os.Stderr, ... )
os.Exit(1)
}
}
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.
ahh nice, so extract all the stuff i am doing in main
to an encapsulating routine (e.g. spliceLogs)
? that's a really good point, i was actually thinking that things were getting repetitive
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.
yes. And since this is a single-use CLI tool, you even get away with globals for the flag variables.
(In contrast to an rpc like thing where these request params would need to be passed as function arguments)
No description provided.