Skip to content

Commit

Permalink
Fuse Over RPC (#222)
Browse files Browse the repository at this point in the history
* commiting to switch

* basics working

* remove added flag

* added in wrong ui

* change back go version

* reset build

* update gazelle and run Close() on file

* gazelle

* fix recursive test from enkit //...

* changes for PR, renaming to be cleaner

* add in rename to fusepb

* net.JoinHostPort

* separate types

* change package name

* rename interfaces

* remove allowother in test
  • Loading branch information
aaahrens authored Oct 25, 2021
1 parent 81bc45c commit 732aec5
Show file tree
Hide file tree
Showing 17 changed files with 747 additions and 4 deletions.
47 changes: 45 additions & 2 deletions bazel/go_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,18 @@ def go_repositories():
sum = "h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=",
version = "v1.0.0",
)
go_repository(
name = "com_github_dvyukov_go_fuzz",
importpath = "github.com/dvyukov/go-fuzz",
sum = "h1:NgO45/5mBLRVfiXerEFzH6ikcZ7DNRPS639xFg3ENzU=",
version = "v0.0.0-20200318091601-be3528f3a813",
)
go_repository(
name = "com_github_elazarl_go_bindata_assetfs",
importpath = "github.com/elazarl/go-bindata-assetfs",
sum = "h1:G/bYguwHIzWq9ZoyUQqrjTmJbbYn3j3CKKpKinvZLFk=",
version = "v1.0.0",
)

go_repository(
name = "com_github_emirpasic_gods",
Expand Down Expand Up @@ -1127,6 +1139,13 @@ def go_repositories():
sum = "h1:TDTW5Yz1mjftljbcKqRcrYhd4XeOoI98t+9HbQbYf7g=",
version = "v1.2.0",
)
go_repository(
name = "com_github_julusian_godocdown",
importpath = "github.com/Julusian/godocdown",
sum = "h1:n3F+mWm+b4D7uNbx1syN/uQTVDwt2sWfk23Mhzwzec4=",
version = "v0.0.0-20170816220326-6d19f8ff2df8",
)

go_repository(
name = "com_github_julz_importas",
importpath = "github.com/julz/importas",
Expand Down Expand Up @@ -1643,6 +1662,12 @@ def go_repositories():
sum = "h1:L8QM9bvf68pVdQ3bCFZMDmnt9yqcMBro1pC7F+IPYMY=",
version = "v0.0.0-20200407221936-30656e2c4a95",
)
go_repository(
name = "com_github_robertkrimen_godocdown",
importpath = "github.com/robertkrimen/godocdown",
sum = "h1:jMxcLa+VjJKhpCwbLUXAD15wJ+hhvXMLujCl3MkXpfM=",
version = "v0.0.0-20130622164427-0bfa04905481",
)

go_repository(
name = "com_github_rogpeppe_fastuuid",
Expand Down Expand Up @@ -1853,6 +1878,12 @@ def go_repositories():
sum = "h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk=",
version = "v0.0.0-20190523213315-cbe66965904d",
)
go_repository(
name = "com_github_stephens2424_writerset",
importpath = "github.com/stephens2424/writerset",
sum = "h1:znRLgU6g8RS5euYRcy004XeE4W+Tu44kALzy7ghPif8=",
version = "v1.0.2",
)

go_repository(
name = "com_github_stretchr_objx",
Expand Down Expand Up @@ -1916,6 +1947,12 @@ def go_repositories():
sum = "h1:a1S4+4HSXDJMgeODJH/t0EEKxcVla6Tasw+Zx9JJMog=",
version = "v2.3.1",
)
go_repository(
name = "com_github_tv42_httpunix",
importpath = "github.com/tv42/httpunix",
sum = "h1:u6SKchux2yDvFQnDHS3lPnIRmfVJ5Sxy3ao2SIdysLQ=",
version = "v0.0.0-20191220191345-2ba4b9c3382c",
)

go_repository(
name = "com_github_ugorji_go",
Expand Down Expand Up @@ -2191,6 +2228,12 @@ def go_repositories():
sum = "h1:xwwDQW5We85NaTk2APgoN9202w/l0DVGp+GZMfsrh7s=",
version = "v0.0.0-20210223155950-e043a3d3c984",
)
go_repository(
name = "org_bazil_fuse",
importpath = "bazil.org/fuse",
sum = "h1:UrYe9YkT4Wpm6D+zByEyCJQzDqTPXqTDUI7bZ41i9VE=",
version = "v0.0.0-20200524192727-fb710f7dfd05",
)

go_repository(
name = "org_golang_google_api",
Expand Down Expand Up @@ -2286,8 +2329,8 @@ def go_repositories():
go_repository(
name = "org_golang_x_sys",
importpath = "golang.org/x/sys",
sum = "h1:46ULzRKLh1CwgRq2dC5SlBzEqqNCi8rreOZnNrbqcIY=",
version = "v0.0.0-20210309074719-68d13333faf2",
sum = "h1:xrCZDmdtoloIiooiA9q0OQb9r8HejIHYoHGhGCe1pGg=",
version = "v0.0.0-20210910150752-751e447fb3d0",
)
go_repository(
name = "org_golang_x_term",
Expand Down
1 change: 1 addition & 0 deletions enkit/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ go_library(
"//lib/client/commands:go_default_library",
"//lib/kflags/kcobra:go_default_library",
"//lib/srand:go_default_library",
"//proxy/enfuse/fusecmd:go_default_library",
"//proxy/ptunnel/commands:go_default_library",
"@com_github_spf13_cobra//:go_default_library",
],
Expand Down
5 changes: 4 additions & 1 deletion enkit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package main

import (
"github.com/enfabrica/enkit/lib/client"
"github.com/enfabrica/enkit/proxy/enfuse/fusecmd"

acommands "github.com/enfabrica/enkit/astore/client/commands"
bcommands "github.com/enfabrica/enkit/lib/client/commands"
bazelcmds "github.com/enfabrica/enkit/lib/bazel/commands"
bcommands "github.com/enfabrica/enkit/lib/client/commands"
tcommands "github.com/enfabrica/enkit/proxy/ptunnel/commands"

"github.com/enfabrica/enkit/lib/kflags/kcobra"
Expand Down Expand Up @@ -48,5 +49,7 @@ func main() {
bazel := bazelcmds.New(base)
root.AddCommand(bazel.Command)

root.AddCommand(fusecmd.New())

base.Run(kcobra.HideFlags(set), populator, runner)
}
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/enfabrica/enkit
go 1.14

require (
bazil.org/fuse v0.0.0-20200524192727-fb710f7dfd05 // indirect
cloud.google.com/go/datastore v1.1.0
cloud.google.com/go/storage v1.10.0
github.com/Microsoft/go-winio v0.4.16 // indirect
Expand Down Expand Up @@ -69,7 +70,7 @@ require (
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 // indirect
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110
golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43
golang.org/x/sys v0.0.0-20210309074719-68d13333faf2 // indirect
golang.org/x/sys v0.0.0-20210910150752-751e447fb3d0 // indirect
google.golang.org/api v0.30.0
google.golang.org/grpc v1.37.0
google.golang.org/protobuf v1.26.0
Expand Down
11 changes: 11 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
4d63.com/gochecknoglobals v0.0.0-20201008074935-acfc0b28355a h1:wFEQiK85fRsEVF0CRrPAos5LoAryUsIX1kPW/WrIqFw=
4d63.com/gochecknoglobals v0.0.0-20201008074935-acfc0b28355a/go.mod h1:wfdC5ZjKSPr7CybKEcgJhUOgeAQW1+7WcyK8OvUilfo=
bazil.org/fuse v0.0.0-20200524192727-fb710f7dfd05 h1:UrYe9YkT4Wpm6D+zByEyCJQzDqTPXqTDUI7bZ41i9VE=
bazil.org/fuse v0.0.0-20200524192727-fb710f7dfd05/go.mod h1:h0h5FBYpXThbvSfTqthw+0I4nmHnhTHkO5BoOHsBWqg=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
Expand Down Expand Up @@ -56,6 +58,7 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802 h1:1BDTz0u9nC3//pOC
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 h1:sHglBQTwgx+rWPdisA5ynNEsoARbiCBOyGcJM4/OzsM=
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24/go.mod h1:4UJr5HIiMZrwgkSPdsjy2uOQExX/WEILpIrO9UPGuXs=
github.com/Julusian/godocdown v0.0.0-20170816220326-6d19f8ff2df8/go.mod h1:INZr5t32rG59/5xeltqoCJoNY7e5x/3xoY9WSWVWg74=
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/Microsoft/go-winio v0.4.16 h1:FtSW/jqD+l4ba5iPBj9CODVtgfYAD8w2wS923g/cFDk=
Expand Down Expand Up @@ -183,6 +186,8 @@ github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/dvyukov/go-fuzz v0.0.0-20200318091601-be3528f3a813/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw=
github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
Expand Down Expand Up @@ -702,6 +707,7 @@ github.com/quasilyte/go-ruleguard/rules v0.0.0-20201231183845-9e62ed36efe1 h1:PX
github.com/quasilyte/go-ruleguard/rules v0.0.0-20201231183845-9e62ed36efe1/go.mod h1:7JTjp89EGyU1d6XfBiXihJNG37wB2VRkd125Q1u7Plc=
github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95 h1:L8QM9bvf68pVdQ3bCFZMDmnt9yqcMBro1pC7F+IPYMY=
github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95/go.mod h1:rlzQ04UMyJXu/aOvhd8qT+hvDrFpiwqp8MRXDY9szc0=
github.com/robertkrimen/godocdown v0.0.0-20130622164427-0bfa04905481/go.mod h1:C9WhFzY47SzYBIvzFqSvHIR6ROgDo4TtdTuRaOMjF/s=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af h1:gu+uRPtBe88sKxUCEXRoeCvVG90TJmwhiqRpvdhQFng=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
Expand Down Expand Up @@ -782,6 +788,7 @@ github.com/spf13/viper v1.7.1 h1:pM5oEahlgWv/WnHXpgbKz7iLIxRf65tye2Ci+XFK5sk=
github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
github.com/ssgreg/nlreturn/v2 v2.1.0 h1:6/s4Rc49L6Uo6RLjhWZGBpWWjfzk2yrf1nIW8m4wgVA=
github.com/ssgreg/nlreturn/v2 v2.1.0/go.mod h1:E/iiPB78hV7Szg2YfRgyIrk1AD6JVMTRkkxBiELzh2I=
github.com/stephens2424/writerset v1.0.2/go.mod h1:aS2JhsMn6eA7e82oNmW4rfsgAOp9COBTTl8mzkwADnc=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down Expand Up @@ -810,6 +817,7 @@ github.com/tomarrell/wrapcheck v0.0.0-20201130113247-1683564d9756 h1:zV5mu0ESwb+
github.com/tomarrell/wrapcheck v0.0.0-20201130113247-1683564d9756/go.mod h1:yiFB6fFoV7saXirUGfuK+cPtUh4NX/Hf5y2WC2lehu0=
github.com/tommy-muehle/go-mnd/v2 v2.3.1 h1:a1S4+4HSXDJMgeODJH/t0EEKxcVla6Tasw+Zx9JJMog=
github.com/tommy-muehle/go-mnd/v2 v2.3.1/go.mod h1:WsUAkMJMYww6l/ufffCD3m+P7LEvr8TnZn9lwVDlgzw=
github.com/tv42/httpunix v0.0.0-20191220191345-2ba4b9c3382c/go.mod h1:hzIxponao9Kjc7aWznkXaL4U4TWaDSs8zcsY4Ka08nM=
github.com/ugorji/go v1.1.4 h1:j4s+tAvLfL3bZyefP2SEWmhBzmuIlH/eqNuPdFPgngw=
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
github.com/ulikunitz/xz v0.5.8 h1:ERv8V6GKqVi23rgu5cj9pVfVzJbOqAY2Ntl88O6c2nQ=
Expand Down Expand Up @@ -1026,6 +1034,7 @@ golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191210023423-ac6580df4449/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down Expand Up @@ -1067,6 +1076,7 @@ golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 h1:RqytpXGR1iVNX7psjB3ff8y7s
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210910150752-751e447fb3d0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
Expand Down Expand Up @@ -1139,6 +1149,7 @@ golang.org/x/tools v0.0.0-20200329025819-fd4102a86c65/go.mod h1:Sl4aGygMT6LrqrWc
golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
golang.org/x/tools v0.0.0-20200414032229-332987a829c3/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200422022333-3d57cf2e726e/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200423201157-2723c5de0d66/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
Expand Down
36 changes: 36 additions & 0 deletions proxy/enfuse/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "go_default_library",
srcs = [
"client.go",
"config.go",
"files.go",
"server.go",
],
importpath = "github.com/enfabrica/enkit/proxy/enfuse",
visibility = ["//visibility:public"],
deps = [
"//proxy/enfuse/rpc:go_default_library",
"@org_bazil_fuse//:go_default_library",
"@org_bazil_fuse//fs:go_default_library",
"@org_golang_google_grpc//:go_default_library",
],
)

go_test(
name = "go_default_test",
srcs = ["e2e_test.go"],
tags = [
"no-sandbox",
],
deps = [
":go_default_library",
"//lib/knetwork:go_default_library",
"//lib/srand:go_default_library",
"//proxy/enfuse/rpc:go_default_library",
"@com_github_stretchr_testify//assert:go_default_library",
"@org_bazil_fuse//fs/fstestutil:go_default_library",
"@org_golang_google_grpc//:go_default_library",
],
)
41 changes: 41 additions & 0 deletions proxy/enfuse/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package enfuse

import (
"bazil.org/fuse"
"bazil.org/fuse/fs"
fusepb "github.com/enfabrica/enkit/proxy/enfuse/rpc"
"google.golang.org/grpc"
"net"
"strconv"
)

var (
_ fs.FS = &FuseClient{}
)

func NewClient(config *ConnectConfig) (*FuseClient, error) {
conn, err := grpc.Dial(net.JoinHostPort(config.Url, strconv.Itoa(config.Port)), grpc.WithInsecure())
if err != nil {
return nil, err
}
return &FuseClient{fusepb.NewFuseControllerClient(conn)}, nil
}

func MountDirectory(mountPath string, client *FuseClient) error {
c, err := fuse.Mount(
mountPath,
)
if err != nil {
return err
}
srv := fs.New(c, nil)
return srv.Serve(client)
}

type FuseClient struct {
ConnClient fusepb.FuseControllerClient
}

func (f *FuseClient) Root() (fs.Node, error) {
return &Dir{Dir: "", Client: f.ConnClient}, nil
}
69 changes: 69 additions & 0 deletions proxy/enfuse/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package enfuse

import (
"net"
)

type ConnectConfig struct {
Port int
Url string
L net.Listener
}

type ConnectMod func(c *ConnectConfig)

var (
WithPort = func(p int) ConnectMod {
return func(c *ConnectConfig) {
c.Port = p
}
}
WithInterface = func(u string) ConnectMod {
return func(c *ConnectConfig) {
c.Url = u
}
}
WithListener = func(l net.Listener) ConnectMod {
return func(c *ConnectConfig) {
c.L = l
}
}
WithConnectConfig = func(c1 *ConnectConfig) ConnectMod {
return func(c *ConnectConfig) {
*c = *c1
}
}
)

type (
ServerConfig struct {
*ConnectConfig
Dir string
}
ServerConfigMod = func(sc *ServerConfig)
)

var (
WithConnectMods = func(c ...ConnectMod) ServerConfigMod {
return func(sc *ServerConfig) {
for _, m := range c {
m(sc.ConnectConfig)
}
}
}
WithDir = func(d string) ServerConfigMod {
return func(sc *ServerConfig) {
sc.Dir = d
}
}
)

func NewServerConfig(mods ...ServerConfigMod) *ServerConfig {
sc := &ServerConfig{
ConnectConfig: &ConnectConfig{},
}
for _, m := range mods {
m(sc)
}
return sc
}
Loading

0 comments on commit 732aec5

Please sign in to comment.