-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathnew_hdfs.go
More file actions
33 lines (29 loc) · 836 Bytes
/
new_hdfs.go
File metadata and controls
33 lines (29 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package example
import (
"fmt"
"os"
hdfs "go.beyondstorage.io/services/hdfs"
"go.beyondstorage.io/v5/pairs"
"go.beyondstorage.io/v5/services"
"go.beyondstorage.io/v5/types"
)
func NewHDFS() (types.Storager, error) {
return hdfs.NewStorager(
// work_dir: https://beyondstorage.io/docs/go-storage/pairs/work_dir
//
// Relative operations will be based on this WorkDir.
pairs.WithWorkDir(os.Getenv("STORAGE_HDFS_WORKDIR")),
// endpoint: https://beyondstorage.io/docs/go-storage/pairs/endpoint
//
// Example Value: tcp:host:port
pairs.WithEndpoint(os.Getenv("STORAGE_HDFS_ENDPOINT")),
)
}
func NewHDFSFromString() (types.Storager, error) {
str := fmt.Sprintf(
"hdfs://%s?endpoint=%s",
os.Getenv("STORAGE_HDFS_WORKDIR"),
os.Getenv("STORAGE_HDFS_ENDPOINT"),
)
return services.NewStoragerFromString(str)
}