worryg0d commented on code in PR #1929:
URL: 
https://github.com/apache/cassandra-gocql-driver/pull/1929#discussion_r2797717527


##########
event_listeners.go:
##########
@@ -0,0 +1,158 @@
+/*
+ * 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.
+ */
+/*
+ * Content before git sha 34fdeebefcbf183ed7f916f931aa0586fdaa1b40
+ * Copyright (c) 2012, The Gocql authors,
+ * provided under the BSD-3-Clause License.
+ * See the NOTICE file distributed with this work for additional information.
+ */
+
+package gocql
+
+import "net"
+
+// TopologyChangeListener receives topology change events.
+// Host may be nil if the node is not yet known to the ring.
+type TopologyChangeListener interface {
+       OnNewNode(event NewNodeEvent)
+       OnRemovedNode(event RemovedNodeEvent)
+}
+
+// TODO: thinking about this, do we actually need different struct for each 
event type?
+// Having structs as a parameter to the event handlers allows us to add more 
fields
+// in the future without breaking the API, but it does add some boilerplate 
code and
+// I'm unsure if we really need it.
+
+type NewNodeEvent struct {
+       Host *HostInfo
+       IP   net.IP
+       Port int
+}
+
+type RemovedNodeEvent struct {
+       Host *HostInfo
+       IP   net.IP
+       Port int
+}
+
+// NodeStatusChangeListener receives node state change events.
+// Host may be nil if the node is not yet known to the ring.
+type NodeStatusChangeListener interface {
+       OnNodeUp(event NodeUpEvent)
+       OnNodeDown(event NodeDownEvent)

Review Comment:
   Yep, I was thinking about this too. I didn't like this duplication, but I 
wanted to make the API consistent with other event listeners.
   
   Thinking about this, `HostStateNotifier` is also responsible for handling 
both TOPOLOGY and STATUS change events, so we can get rid of the 
TopologyChangeListener as well.
   ```
   // HostStateNotifier is an interface for notifying about host state changes.
   // It allows host selection policies to be informed when hosts are added, 
removed,
   // or change their availability status.
   type HostStateNotifier interface {
        AddHost(host *HostInfo)
        RemoveHost(host *HostInfo)
        HostUp(host *HostInfo)
        HostDown(host *HostInfo)
   }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to