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

Log splicer rewrite #9

Merged
merged 3 commits into from
Jun 21, 2021
Merged

Log splicer rewrite #9

merged 3 commits into from
Jun 21, 2021

Conversation

cblgh
Copy link
Contributor

@cblgh cblgh commented Jun 21, 2021

No description provided.

@cblgh cblgh force-pushed the log-splicer-rewrite branch from d43e8aa to 53495c6 Compare June 21, 2021 12:12
@@ -20,9 +26,12 @@ import (
"go.cryptoscope.co/margaret/legacyflumeoffset"
)

// TODO: collapse feedinfo + feedjson into just feedinfo? and use temp struct for unmarshaling ID?
Copy link
Contributor Author

@cblgh cblgh Jun 21, 2021

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

Copy link
Member

Choose a reason for hiding this comment

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

remove the comment then :)

Copy link
Member

@cryptix cryptix left a 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!

@@ -20,9 +26,12 @@ import (
"go.cryptoscope.co/margaret/legacyflumeoffset"
)

// TODO: collapse feedinfo + feedjson into just feedinfo? and use temp struct for unmarshaling ID?
Copy link
Member

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
Copy link
Member

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)

Copy link
Contributor Author

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.

🤣


_, 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)
Copy link
Member

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)
  }
}

Copy link
Contributor Author

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

Copy link
Member

@cryptix cryptix Jun 21, 2021

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)

@cblgh cblgh merged commit 270ec76 into main Jun 21, 2021
@cblgh cblgh deleted the log-splicer-rewrite branch June 21, 2021 13:34
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