Merge pull request #1578 from NickrenREN/sysfs-new

optimize NewRealSysFs()
This commit is contained in:
David Ashpole 2017-03-14 21:28:05 -07:00 committed by GitHub
commit fb28b0da1b
3 changed files with 4 additions and 10 deletions

View File

@ -117,10 +117,7 @@ func main() {
glog.Fatalf("Failed to initialize storage driver: %s", err)
}
sysFs, err := sysfs.NewRealSysFs()
if err != nil {
glog.Fatalf("Failed to create a system interface: %s", err)
}
sysFs := sysfs.NewRealSysFs()
collectorHttpClient := createCollectorHttpClient(*collectorCert, *collectorKey)

View File

@ -70,8 +70,8 @@ type SysFs interface {
type realSysFs struct{}
func NewRealSysFs() (SysFs, error) {
return &realSysFs{}, nil
func NewRealSysFs() SysFs {
return &realSysFs{}
}
func (self *realSysFs) GetBlockDevices() ([]os.FileInfo, error) {

View File

@ -155,10 +155,7 @@ func GetCacheInfo(sysFs sysfs.SysFs, id int) ([]sysfs.CacheInfo, error) {
func GetNetworkStats(name string) (info.InterfaceStats, error) {
// TODO(rjnagal): Take syfs as an argument.
sysFs, err := sysfs.NewRealSysFs()
if err != nil {
return info.InterfaceStats{}, err
}
sysFs := sysfs.NewRealSysFs()
return getNetworkStats(name, sysFs)
}