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

Cleanup, Metrics, Closed Leaks #1

Closed
wants to merge 48 commits into from
Closed

Cleanup, Metrics, Closed Leaks #1

wants to merge 48 commits into from

Conversation

keks
Copy link
Contributor

@keks keks commented Nov 25, 2018

All the good stuff. Making this a PR so I can properly review.

Copy link
Contributor Author

@keks keks left a comment

Choose a reason for hiding this comment

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

OMG this is so great! There are a couple of remarks.

One thing I'm not sure about is the Authorization stuff. I don't like the pmgr/ctrl distinction, but I'm okay to let it go in like this for now until we find a nice abstraction for this.

.travis.yml Show resolved Hide resolved
wmgr := &wantManager{
bs: bs,
wants: make(map[string]int64),
info: log,
}

for i, o := range opts {
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 think we should use proper typed functional options for this. I started working on this, so if you want I can push it.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed in general but I wasn't sure if I want to keep them anyways... I'm still not sure about the best way to partially inject these counters. It's really easy to wrap a whole interface but in some cases that isn't possible.

My biggest dislike is all the if gauge != nil { .Add(1) } lines which I want to place with functions at least before merging this. I'm all yours for better ideas.. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I think we'll have to discuss the partial injection in person, I don't really know what you mean by it. But I see what you mean about the conditional adds... I don't know the prometheus API enough to comment on that, but in general it would be nice not to have a hard dependency on prometheus... maybe adding hooks or something like that is a better approach?

blobstore/wants.go Outdated Show resolved Hide resolved
blobstore/wants.go Outdated Show resolved Hide resolved

// TODO: ctx?? this pours into the broadcast, right?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, this function should probably take a context...

@@ -26,8 +28,14 @@ import (
"go.cryptoscope.co/ssb/repo"
)

func ckFatal(err error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why are you exiting instead of using assert/require/testing.T?

Copy link
Member

Choose a reason for hiding this comment

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

you can't use t.Error / t.Fatal inside of goroutines. So neither assert or require. There might be a nicer way using chan err or something but I wanted understandable behavior first.

See golang/go#17900 or ipfs/kubo#2043

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, I see. Yeah I think we should use an chan error for that, but I see why you did it how you did. Not sure what the best way is - maybe let everything run in goroutines in the test goroutine just read the error chans that all the goroutines write to?

Copy link
Member

Choose a reason for hiding this comment

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

yea sounds good but let's make this a meta-todo for all the repos then.

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'll gently start the effort by opening an issue to open issues everywhere...

plugins/gossip/plugin.go Show resolved Hide resolved
@@ -19,17 +19,20 @@ func (h *handler) pourFeed(ctx context.Context, req *muxrpc.Request) error {
return errors.New("not enough arguments, expecting feed id")
}
qv := req.Args[0].(map[string]interface{})
if id, ok := qv["id"]; ok && id == `@S9lG7keeOfIAepU1LRD9XUDtuesbejRC2+3/FRaGZ3s=.sha256` {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can we not hardcode this, and instead just drop errors like this in general? It's super easy to add more like this to the system, and I don't want to maintain an official list of broken messages.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry but I don't see the alternative, if you are suggesting one? I don't want to spam our logs with this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, maybe just swallow the error from ParseFeedRef and silently abort if it fails? Or better, return an error if it does not have the structure of a feed ref, but silently swallow errors on unknown/ridiculous algorithms. Do that by using typed errors in ParseFeedRef.

Copy link
Member

Choose a reason for hiding this comment

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

phew... don't see much point in that complexity either. I changed it to ignore everything that isn't a valid feed ref now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SGTM. My thinking was that a generic "process a message" function maybe shouldn't silently abort, but this error also should not be printed every time it happens. That was what I came up with to make this distinguishable.

sbot/new.go Show resolved Hide resolved
control/handler.go Outdated Show resolved Hide resolved
add seperate connect command to sbotcli

also adds whoami and blobs commands to the control handler
@cryptix
Copy link
Member

cryptix commented Jan 12, 2019

merged manually

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