File tree Expand file tree Collapse file tree 5 files changed +40
-11
lines changed
core/src/main/scala/app/softnetwork Expand file tree Collapse file tree 5 files changed +40
-11
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ ThisBuild / organization := "app.softnetwork"
1919
2020name := " softclient4es"
2121
22- ThisBuild / version := " 0.10.0 "
22+ ThisBuild / version := " 0.10.1 "
2323
2424ThisBuild / scalaVersion := scala213
2525
Original file line number Diff line number Diff line change 1+ package app .softnetwork
2+
3+ import org .slf4j .Logger
4+
5+ import java .io .Closeable
6+
7+ package object common {
8+
9+ trait ClientCompanion extends Closeable { _ : { def logger : Logger } =>
10+
11+ /** Check if client is initialized and connected
12+ */
13+ def isInitialized : Boolean
14+
15+ /** Test connection
16+ * @return
17+ * true if connection is successful
18+ */
19+ def testConnection (): Boolean
20+ }
21+
22+ }
Original file line number Diff line number Diff line change 1616
1717package app .softnetwork .elastic .client
1818
19+ import app .softnetwork .common .ClientCompanion
1920import com .typesafe .config .{Config , ConfigFactory }
2021import org .json4s .jackson
2122import org .json4s .jackson .Serialization
@@ -44,7 +45,7 @@ trait ElasticClientApi
4445 with FlushApi
4546 with VersionApi
4647 with SerializationApi
47- with Closeable {
48+ with ClientCompanion {
4849
4950 protected def logger : Logger
5051
Original file line number Diff line number Diff line change 1616
1717package app .softnetwork .elastic .client
1818
19+ import app .softnetwork .common .ClientCompanion
1920import org .apache .http .HttpHost
2021import org .slf4j .Logger
2122
@@ -25,7 +26,7 @@ import java.util.concurrent.atomic.AtomicInteger
2526import scala .language .reflectiveCalls
2627import scala .util .{Failure , Success , Try }
2728
28- trait ElasticClientCompanion [T <: Closeable ] extends Closeable { _ : { def logger : Logger } =>
29+ trait ElasticClientCompanion [T <: Closeable ] extends ClientCompanion { _ : { def logger : Logger } =>
2930
3031 def elasticConfig : ElasticConfig
3132
@@ -140,13 +141,7 @@ trait ElasticClientCompanion[T <: Closeable] extends Closeable { _: { def logger
140141
141142 /** Check if client is initialized and connected
142143 */
143- def isInitialized : Boolean = client.isDefined
144-
145- /** Test connection to Elasticsearch cluster
146- * @return
147- * true if connection is successful
148- */
149- def testConnection (): Boolean
144+ override def isInitialized : Boolean = client.isDefined
150145
151146 /** Close the client and release resources Idempotent - safe to call multiple times
152147 */
Original file line number Diff line number Diff line change @@ -41,10 +41,21 @@ trait ElasticClientDelegator extends ElasticClientApi with BulkTypes {
4141 // Delegate config to the underlying client
4242 override lazy val config : Config = delegate.config
4343
44- // ==================== Closeable ====================
44+ // ==================== ClientCompanion ====================
4545
4646 override def close (): Unit = delegate.close()
4747
48+ /** Check if client is initialized and connected
49+ */
50+ override def isInitialized : Boolean = delegate.isInitialized
51+
52+ /** Test connection
53+ *
54+ * @return
55+ * true if connection is successful
56+ */
57+ override def testConnection (): Boolean = delegate.testConnection()
58+
4859 // ==================== VersionApi ====================
4960
5061 /** Get Elasticsearch version.
You can’t perform that action at this time.
0 commit comments