-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7868f8d
commit f070475
Showing
7 changed files
with
60 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
//go:build !prod | ||
|
||
package assets | ||
|
||
import "embed" | ||
|
||
//go:embed mock-data | ||
var MockData embed.FS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
//go:build !prod | ||
|
||
package metrics | ||
|
||
import ( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
//go:build !prod | ||
package metrics | ||
|
||
import ( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
//go:build prod | ||
|
||
package metrics | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
|
||
"github.com/moderato-app/live-pprof/api" | ||
"github.com/moderato-app/live-pprof/internal/logging" | ||
) | ||
|
||
var mockNotAvailableErr = errors.New("mock data is not available for a prod build") | ||
|
||
// MockMetricsServer returns mock data instead of real data to save development time | ||
type MockMetricsServer struct { | ||
api.UnimplementedMockMetricsServer | ||
} | ||
|
||
func NewMockMetricsServer() *MockMetricsServer { | ||
return &MockMetricsServer{} | ||
} | ||
|
||
func (m *MockMetricsServer) HeapMetrics(_ context.Context, req *api.GoMetricsRequest) (*api.GoMetricsResponse, error) { | ||
logging.Sugar.Debug("HeapMetrics req:", req) | ||
return nil, mockNotAvailableErr | ||
} | ||
|
||
func (m *MockMetricsServer) CPUMetrics(_ context.Context, req *api.GoMetricsRequest) (*api.GoMetricsResponse, error) { | ||
logging.Sugar.Debug("CPUMetrics req:", req) | ||
return nil, mockNotAvailableErr | ||
} | ||
|
||
func (m *MockMetricsServer) AllocsMetrics(_ context.Context, req *api.GoMetricsRequest) (*api.GoMetricsResponse, error) { | ||
logging.Sugar.Debug("AllocsMetrics req:", req) | ||
return nil, mockNotAvailableErr | ||
} | ||
|
||
func (m *MockMetricsServer) GoroutineMetrics(_ context.Context, req *api.GoMetricsRequest) (*api.GoMetricsResponse, error) { | ||
logging.Sugar.Debug("GoroutineMetrics req:", req) | ||
return nil, mockNotAvailableErr | ||
} |