HDFSWriter microservice working copy
[demo.git] / vnfs / DAaaS / microservices / GoApps / src / go-hdfs-writer / pkg / utils / hdfsUtils.go
diff --git a/vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/hdfsUtils.go b/vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/hdfsUtils.go
new file mode 100644 (file)
index 0000000..1a93a5a
--- /dev/null
@@ -0,0 +1,33 @@
+package utils
+
+import (
+       "fmt"
+       "github.com/colinmarc/hdfs"
+       //"sync"
+       //"go.uber.org/zap"
+)
+
+
+//var clientOnce sync.Once
+//var hdfsClient *hdfs.Client
+//var slogger *zap.SugaredLogger
+
+
+//GetHdfsClientInstance returns a singleton hdfsClient instance
+// func GetHdfsClientInstance(hdfsURL string) (*hdfs.Client){
+//     clientOnce.Do(func(){
+//             hdfsClient = createHdfsClient(hdfsURL)
+//     })
+//     return hdfsClient
+// }
+
+//CreateHdfsClient creates a hdfs client and returns hdfs client
+func CreateHdfsClient(hdfsURL string) (*hdfs.Client){
+       slogger := GetLoggerInstance()
+       hdfsClient, hdfsConnectError := hdfs.New(hdfsURL)
+       if hdfsConnectError !=nil {
+               slogger.Fatalf(":::Error in create hdfsClient::: %v", hdfsConnectError)
+               fmt.Printf("::Unable to initialize hdfsURL, check logs")
+       }
+       return hdfsClient
+}
\ No newline at end of file