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

All functions are public, so which ones are part of the external API? #1

Open
qedus opened this issue Dec 9, 2013 · 3 comments
Open

Comments

@qedus
Copy link

qedus commented Dec 9, 2013

As the title says all functions in https://github.com/pubnub/go/blob/master/pubnubMessaging/pubnub.go are public making it impossible to determine which ones are part of the internal workings of the Go client implementation and which are part of the API. In Go public functions are ones that start with an uppercase letter, private ones are those that start with a lowercase one.

Looking at the code, it could do with a rewrite to make it more Go idiomatic. I would advise removing any API dependence on Go channels and doing something like the websocket implementation http://godoc.org/code.google.com/p/go.net/websocket

@crimsonred
Copy link
Contributor

Hi @qedus ,

Thanks for the feedback. We plan to to differentiate between the public functions and private ones in the next iteration.

We have used the channels to provide the feature of async callbacks (in case of error and response), to the caller methods. Internally we use the "http" package to communicate with PubNub origin. (if that is what you meant by the comment on websockets)

Please have a look at the example (https://github.com/pubnub/go/blob/master/pubnubExample/pubnubExample.go) or tests (https://github.com/pubnub/go/tree/master/pubnubTests) for an example implementations.

Thanks,
Rajat

@qedus
Copy link
Author

qedus commented Dec 9, 2013

Hi @crimsonred

Thanks for the update.

With regards to the channels, I read a document somewhere by the designers of Go Lang about how to create a good Go API. The document advised not to build concurrency requirements (eg channels) into the API unless absolutely necessary and let the user of the API decide how to deal with concurrency. The main reason for this is you generally get a cleaner and easier to use API. I had a quick look for the doc but can't find it. Maybe you could ask on golang-nuts Google Group?

I gave the websocket example as something that receives asynchronous requests but does not require the user to think about concurrency with the API. Personally, I have wrapped your API in a blocking 'Read' function that loops. Here's some pseudocode of how my setup works: https://gist.github.com/qedus/7873377

Thanks,
Jon

@crimsonred
Copy link
Contributor

Hi @qedus ,

Thanks for the detailed explanation. I see what you mean. I will discuss this valuable point with my team and keep you posted on the updates.

Thanks,
Rajat

@qedus qedus mentioned this issue Dec 17, 2013
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

No branches or pull requests

1 participant