You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2015/03/16 19:18:10 UTC

qpid-proton git commit: PROTON-827: Removed go examples.

Repository: qpid-proton
Updated Branches:
  refs/heads/master fac7c86c8 -> 51ddf8a7c


PROTON-827: Removed go examples.

My evolving understanding of Go makes me feel these examples are not right.
Watch this space.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/51ddf8a7
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/51ddf8a7
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/51ddf8a7

Branch: refs/heads/master
Commit: 51ddf8a7cc8c0b93c6d6f0c19ffa49ba7c52c2a0
Parents: fac7c86
Author: Alan Conway <ac...@redhat.com>
Authored: Mon Mar 16 14:17:01 2015 -0400
Committer: Alan Conway <ac...@redhat.com>
Committed: Mon Mar 16 14:17:58 2015 -0400

----------------------------------------------------------------------
 examples/go/README.md          | 17 --------
 examples/go/listen.go          | 64 ------------------------------
 examples/go/send.go            | 77 -------------------------------------
 proton-c/bindings/go/README.md | 16 ++++++++
 4 files changed, 16 insertions(+), 158 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/51ddf8a7/examples/go/README.md
----------------------------------------------------------------------
diff --git a/examples/go/README.md b/examples/go/README.md
deleted file mode 100644
index 0d86a62..0000000
--- a/examples/go/README.md
+++ /dev/null
@@ -1,17 +0,0 @@
-# *EXPERIMENTAL* Go examples for proton.
-
-See ../../proton-c/bindings/go/README.md
-
-These are sketches of examples for the experimental Go binding.
-
-They don't have sufficient error handling.
-
-They compile and run but do nothing as the binding implementation is just stubs right now.
-
-- listen.go: listens on a port, prints any messages it receives.
-- send.go: sends command-line arguments as messages with string bodies.
-
-You can use the two together, e.g. to listen/send on port 1234:
-
-go run listen.go -addr :1234
-go run send.go -addr :1234 foo bar 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/51ddf8a7/examples/go/listen.go
----------------------------------------------------------------------
diff --git a/examples/go/listen.go b/examples/go/listen.go
deleted file mode 100644
index 95285dd..0000000
--- a/examples/go/listen.go
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied.  See the License for the
-specific language governing permissions and limitations
-under the License.
-*/
-
-package main
-
-import (
-	"flag"
-	"fmt"
-	"net"
-	"os"
-	"qpid.apache.org/proton"
-)
-
-// A message handler type
-type Receiver struct{}
-
-// OnMessage is called when an AMQP message is received.
-func (r *Receiver) OnMessage(e *proton.Event) {
-	fmt.Printf("%#v\n", e.Message)
-}
-
-var addr = flag.String("addr", ":amqp", "Listening address, e.g. localhost:1234")
-
-func main() {
-	flag.Usage = func() {
-		fmt.Fprintln(os.Stderr, "Listen for AMQP messages and print them to stdout until killed.")
-		flag.PrintDefaults()
-	}
-	flag.Parse()
-
-	// Listen for and accept connections using the standard Go net package.
-	listener, err := net.Listen("tcp", *addr)
-	if err != nil {
-		fmt.Fprintf(os.Stderr, "Listen error: %s\n", err)
-		os.Exit(1)
-	}
-	for {
-		conn, err := listener.Accept()
-		if err != nil {
-			fmt.Fprintf(os.Stderr, "Accept error: %s\n", err)
-			continue
-		}
-		fmt.Printf("Accepted connection %s<-%s\n", conn.LocalAddr(), conn.RemoteAddr())
-		// Run processes an AMQP connection and invokes the supplied handler.
-		// In this case it will call (*Receiver) OnMessage when a message is received.
-		go proton.Run(conn, &Receiver{})
-	}
-}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/51ddf8a7/examples/go/send.go
----------------------------------------------------------------------
diff --git a/examples/go/send.go b/examples/go/send.go
deleted file mode 100644
index 13d749d..0000000
--- a/examples/go/send.go
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied.  See the License for the
-specific language governing permissions and limitations
-under the License.
-*/
-
-package main
-
-import (
-	"flag"
-	"fmt"
-	"net"
-	"os"
-	"qpid.apache.org/proton"
-)
-
-// A message handler type
-type Sender struct {
-	Messages       []string
-	Sent, Accepted int
-	Sender         *proton.Sender
-}
-
-// Called when proton.Run is first called on a connection.
-func (s *Sender) OnStart(e *proton.Event) {
-	// Create a sender
-	// FIXME aconway 2015-03-13: Creating sendders on other connections?
-	s.Sender = e.Connection().NewSender("sender")
-}
-
-// Called when a sender has credit to send messages. Send all of flag.Args()
-func (s *Sender) OnSendable(e *proton.Event) {
-	for e.Sender().Credit() > 0 && s.Sent < len(flag.Args()) {
-		// FIXME aconway 2015-03-13: error handling
-		e.Sender().Send(&proton.Message{Body: s.Messages[s.Sent]})
-		s.Sent++
-	}
-}
-
-func (s *Sender) OnAccepted(e *proton.Event) {
-	s.Accepted++
-	if s.Accepted == len(flag.Args()) {
-		e.Connection().Close()
-	}
-}
-
-var addr = flag.String("addr", ":amqp", "Listening address, e.g. localhost:1234")
-
-func main() {
-	flag.Usage = func() {
-		fmt.Fprintln(os.Stderr, "Send AMQP messages with string bodies, one for each argument.")
-		flag.PrintDefaults()
-	}
-	flag.Parse()
-
-	conn, err := net.Dial("tcp", *addr)
-	if err != nil {
-		fmt.Fprintf(os.Stderr, "Dial error: %s\n", err)
-		os.Exit(1)
-	}
-	// Run processes an AMQP connection and invokes the supplied handler.
-	// In this case it will call OnStart.
-	proton.Run(conn, &Sender{Messages: flag.Args()})
-}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/51ddf8a7/proton-c/bindings/go/README.md
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/README.md b/proton-c/bindings/go/README.md
index 8f31b54..c8c32b1 100644
--- a/proton-c/bindings/go/README.md
+++ b/proton-c/bindings/go/README.md
@@ -33,6 +33,22 @@ There are two types of developer we want to support
 We will follow conventions of the C and python API where possible to help
 cross-language developers but idiomatic Go is the overriding consideration.
 
+## API design thoughts
+
+The original idea was to provide a reactive API similar to the proton C and
+python APIs reavctive APIs. Looking more carefully at Go this does not seem like
+the right direction. Go provides built-in fine-grained concurrency and
+specifically aims to reduce the complexity traditional designs based on polling,
+callbacks and threading with communication between concurrent goroutines.
+
+So my current thinking is to build on the C reactor API as the internal core,
+but present message exchange to the user as messages on Go channels. There is a
+strong resemblence between Go channels and AMQP links that we can exploit.
+
+The reactor model probably still has a role for advanced users that want fine
+control over specifc AMPQ protocol features. The challenge will be to fit these
+models together.
+
 ## Status
 
 Marshal and unmarshal most of the AMQP types (TODO: described, array)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org