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

Issue #108: moved subscribe logic from pub to sub and xsub sockets. #112

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

stitchinthyme
Copy link

Also added a subscribe all in proxy.go, because otherwise it won't work with pub/sub sockets. This has no effect for other socket types.

Copy link
Contributor

@sbinet sbinet left a comment

Choose a reason for hiding this comment

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

apologies for the belated review.

I have a couple of cosmetics comments, see below.

also: could you add an example that shows the new semantics? (or a test?)

thanks a lot.

xsub.go Outdated Show resolved Hide resolved
xsub.go Show resolved Hide resolved
proxy.go Outdated Show resolved Hide resolved
pub.go Show resolved Hide resolved
sub.go Outdated Show resolved Hide resolved
xsub.go Outdated Show resolved Hide resolved
xsub.go Show resolved Hide resolved
Copy link
Contributor

@sbinet sbinet left a comment

Choose a reason for hiding this comment

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

one last wrinkle to iron out.

could you also send another PR against go-zeromq/license adding yourself to the AUTHORS and/or CONTRIBUTORS files?

thanks again.

proxy.go Outdated Show resolved Hide resolved
proxy_test.go Outdated Show resolved Hide resolved
xsub.go Show resolved Hide resolved
proxy_test.go Outdated Show resolved Hide resolved
@sbinet
Copy link
Contributor

sbinet commented Sep 27, 2021

thanks for the update.
it seems the tests fail to compile:

# github.com/go-zeromq/zmq4_test [github.com/go-zeromq/zmq4.test]
Error: ./proxy_test.go:321:24: multiple-value zmq4.NewProxy() in single-value context
FAIL	github.com/go-zeromq/zmq4 [build failed]
FAIL
Error: Process completed with exit code 2.

we're nearly there :)

@stitchinthyme
Copy link
Author

stitchinthyme commented Sep 27, 2021 via email

@sbinet
Copy link
Contributor

sbinet commented Sep 27, 2021

two remaining issues:

=== RUN   TestTopics
--- FAIL: TestTopics (0.50s)
panic: interface conversion: *zmq4.pubSocket is not zmq4.Topics: missing method Topics [recovered]
	panic: interface conversion: *zmq4.pubSocket is not zmq4.Topics: missing method Topics

and the linter detected:

Error: func `(*Conn).subscribed` is unused (unused)
Error: func `(*Conn).subscribe` is unused (unused)

@stitchinthyme
Copy link
Author

stitchinthyme commented Sep 27, 2021 via email

@stitchinthyme
Copy link
Author

Sigh...copypasta gets me every time. :-/

@stitchinthyme
Copy link
Author

So I removed "topics" from the Conn object because it doesn't look like it's needed -- the sub and xsub sockets have their own topics. But socket.topics() looks at that...so just trying to figure out if there really needs to be a topics field in Conn.

@stitchinthyme
Copy link
Author

Also, is there a way I can run this lint check?

@sbinet
Copy link
Contributor

sbinet commented Sep 28, 2021

the lint stuff is a bit cumbersome to run locally.

but running go test -v ./... should catch most of what the linter complains about.

originally, (x)pub and (x)sub would both know the topics they were (resp.) publishing or subscribing via this socket.topics.
with the new scheme, it seems to me only (x)sub know.
so... perhaps we should just drop Conn.topics and socket.topics altogether if not knowing/implementing Topics for (x)pub is alright.

I don't remember off-hand whether a (x)pub socket is expected to know the topics it is publishing.
if it's alright, then we can drop that.

@stitchinthyme
Copy link
Author

stitchinthyme commented Sep 28, 2021 via email

@sbinet
Copy link
Contributor

sbinet commented Sep 28, 2021

that's quite strange:

$> cat zall_test.go 
// Copyright 2020 The go-zeromq Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package zmq4

import (
	"io/ioutil"
	"log"
)

var (
	Devnull = log.New(ioutil.Discard, "zmq4: ", 0)
)

what version of Go are you using?

@stitchinthyme
Copy link
Author

stitchinthyme commented Sep 28, 2021 via email

@stitchinthyme
Copy link
Author

stitchinthyme commented Sep 29, 2021 via email

@stitchinthyme
Copy link
Author

I totally do not understand this line (which is what seems to be a problem for the build):

got := sub.(zmq4.Topics).Topics()

(zmq4_xpubsub_test.go:147)

@sbinet
Copy link
Contributor

sbinet commented Sep 29, 2021

this does an interface-cast: it "casts" the sub variable to the zmq4.Topics interface and then call the Topics() method of that interface.

the pure-Go sub sockets do implement the Topics interface.
but the shims to the C++ ones do not.

you seem to have moved that code from the TestTopics func (that's only run on pure-Go sockets) to the TestXPubSub one, that does exercize the Go/Go, Go/C++, C++/Go and C++/C++ cases.

I guess replacing that snippet of code from TextXPubSub with:

got, ok := sub.(zmq4.Topics).Topics() // C++ sockets do not implement the zmq4.Topics interface.
want := []string{topics[isub]}
if ok && !reflect.DeepEqual(got, want) {
	t.Fatalf("Missing or wrong topics.\ngot= %q\nwant=%q", got, want)
}

@stitchinthyme
Copy link
Author

stitchinthyme commented Sep 29, 2021 via email

@codecov
Copy link

codecov bot commented Sep 29, 2021

Codecov Report

Merging #112 (a608850) into master (7ab29a1) will decrease coverage by 2.69%.
The diff coverage is 30.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #112      +/-   ##
==========================================
- Coverage   68.08%   65.39%   -2.70%     
==========================================
  Files          29       29              
  Lines        1811     1832      +21     
==========================================
- Hits         1233     1198      -35     
- Misses        479      534      +55     
- Partials       99      100       +1     
Impacted Files Coverage Δ
conn.go 52.67% <ø> (-3.65%) ⬇️
socket.go 82.80% <ø> (-0.24%) ⬇️
xpub.go 66.66% <0.00%> (-6.67%) ⬇️
xsub.go 14.28% <7.40%> (-35.72%) ⬇️
proxy.go 86.07% <33.33%> (-4.60%) ⬇️
pub.go 69.91% <66.66%> (+0.80%) ⬆️
sub.go 80.64% <100.00%> (+4.17%) ⬆️
rep.go 69.17% <0.00%> (-7.52%) ⬇️
pull.go 76.92% <0.00%> (+7.69%) ⬆️

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 7ab29a1...a608850. Read the comment docs.

@stitchinthyme
Copy link
Author

Ok, I have no idea why the build is still failing or what the "Codecov Report" means.

@sbinet
Copy link
Contributor

sbinet commented Sep 29, 2021

It seems one of the tests deadlocks, but only with 1.17...

Oh well...

I'll have a look next week: I am off the grid starting now until Wednesday next week.

In the meantime, could send another pull request against the 'license' repository, adding yourself to the 'AUTHORS' and/or 'CONTRIBUTORS' ?
When I am back I'll merge the 2 PRs (after having fixed the locked test, unless you beat me to it).

Apologies for the bumpy ride and delay(s)

@stitchinthyme
Copy link
Author

stitchinthyme commented Oct 2, 2021 via email

@sbinet
Copy link
Contributor

sbinet commented Oct 13, 2021

(I haven't forgotten about this PR. but $DAYWORK happened)

@sbinet
Copy link
Contributor

sbinet commented Nov 8, 2021

ok, so...

How likely am I to be inviting (more) spam by adding my email?

well, I haven't seen any uptick of spam in my inbox although I have my address in a few CONTRIBUTORS files on GitHub (golang, gonum, ...).

if you prefer, you could just put your name + GitHub handle.

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