Skip to content

Commit

Permalink
Merge branch 'main' of github.com:rudderlabs/rudder-cp-sdk into chore…
Browse files Browse the repository at this point in the history
….poc
  • Loading branch information
achettyiitr committed Feb 1, 2024
2 parents 6bf7dcf + d4debaa commit 45e5960
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
3 changes: 1 addition & 2 deletions internal/clients/namespace/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package namespace

import (
"context"
"errors"
"net/http"
"time"

Expand Down Expand Up @@ -48,5 +47,5 @@ func (c *Client) GetWorkspaceConfigs(ctx context.Context) (*modelv2.WorkspaceCon
}

func (c *Client) GetUpdatedWorkspaceConfigs(ctx context.Context, updatedAfter time.Time) (*modelv2.WorkspaceConfigs, error) {
return nil, errors.New("not implemented")
return c.GetWorkspaceConfigs(ctx)
}
3 changes: 1 addition & 2 deletions internal/clients/workspace/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package workspace

import (
"context"
"errors"
"net/http"
"time"

Expand Down Expand Up @@ -48,5 +47,5 @@ func (c *Client) GetWorkspaceConfigs(ctx context.Context) (*modelv2.WorkspaceCon
}

func (c *Client) GetUpdatedWorkspaceConfigs(ctx context.Context, updatedAfter time.Time) (*modelv2.WorkspaceConfigs, error) {
return nil, errors.New("not implemented")
return c.GetWorkspaceConfigs(ctx)
}
3 changes: 3 additions & 0 deletions internal/poller/poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"fmt"
"time"

"github.com/rudderlabs/rudder-cp-sdk/profiler"

"github.com/rudderlabs/rudder-cp-sdk/modelv2"
"github.com/rudderlabs/rudder-go-kit/logger"
)
Expand Down Expand Up @@ -84,6 +86,7 @@ func (p *Poller) poll(ctx context.Context) error {

response = wcs
}
profiler.MemProfile(p.log)

if err := p.handler(response); err != nil {
return fmt.Errorf("failed to handle workspace configs: %w", err)
Expand Down
21 changes: 21 additions & 0 deletions profiler/profiler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package profiler

import (
"fmt"
"math/rand"
"os"
"runtime/pprof"
"time"

"github.com/rudderlabs/rudder-go-kit/logger"
)

var r = rand.New(rand.NewSource(time.Now().UnixNano()))

func MemProfile(log logger.Logger) {
f, _ := os.Create(fmt.Sprintf("heap-%d.pprof", r.Int()))
_ = pprof.WriteHeapProfile(f)
_ = f.Close()

log.Infof("heap profile written to %s", f.Name())
}

0 comments on commit 45e5960

Please sign in to comment.