From 4b2fc2d050c00c38fedba33002a3247c12e43c57 Mon Sep 17 00:00:00 2001 From: Ashesh Vidyut Date: Tue, 13 Jun 2023 15:28:30 +0530 Subject: [PATCH] using mmap instead of disk files --- command/connect/envoy/exec_windows.go | 4 +++- go.mod | 1 + go.sum | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/command/connect/envoy/exec_windows.go b/command/connect/envoy/exec_windows.go index 61f0404839..8e2fdca992 100644 --- a/command/connect/envoy/exec_windows.go +++ b/command/connect/envoy/exec_windows.go @@ -12,13 +12,15 @@ import ( "path/filepath" "time" + + "github.com/go-mmap/mmap" ) func makeBootstrapTemp(bootstrapJSON []byte) (string, error) { tempFile := filepath.Join(os.TempDir(), fmt.Sprintf("envoy-%x-bootstrap.json", time.Now().UnixNano()+int64(os.Getpid()))) - f, err := os.Create(tempFile) + f, err := mmap.Open(tempFile, mmap.Write) if err != nil { return tempFile, err } diff --git a/go.mod b/go.mod index 89ef735d98..8f4c6f4f36 100644 --- a/go.mod +++ b/go.mod @@ -155,6 +155,7 @@ require ( github.com/form3tech-oss/jwt-go v3.2.2+incompatible // indirect github.com/go-logr/logr v1.2.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-mmap/mmap v0.7.0 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-openapi/analysis v0.21.4 // indirect github.com/go-openapi/errors v0.20.3 // indirect diff --git a/go.sum b/go.sum index 59ebf57327..14190d3923 100644 --- a/go.sum +++ b/go.sum @@ -315,6 +315,8 @@ github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-mmap/mmap v0.7.0 h1:+h1n06sZw0IWBwL9YDzTomNNXxM4LH/l+HVpGaTC+qk= +github.com/go-mmap/mmap v0.7.0/go.mod h1:moN8m00bW6Mpk+Y1xQFeL3xZqycnT4qUAf852ICV/Gc= github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-openapi/analysis v0.21.2/go.mod h1:HZwRk4RRisyG8vx2Oe6aqeSQcoxRp47Xkp3+K6q+LdY=