github.com/filecoin-project/bacalhau@v0.3.23-0.20230228154132-45c989550ace/pkg/compute/publicapi/client.go (about)

     1  package publicapi
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/filecoin-project/bacalhau/pkg/model"
     7  	"github.com/filecoin-project/bacalhau/pkg/publicapi"
     8  	"github.com/filecoin-project/bacalhau/pkg/system"
     9  )
    10  
    11  // ComputeAPIClient is a utility for interacting with a node's API server.
    12  type ComputeAPIClient struct {
    13  	publicapi.APIClient
    14  }
    15  
    16  // NewComputeAPIClient returns a new client for a node's API server.
    17  func NewComputeAPIClient(baseURI string) *ComputeAPIClient {
    18  	return NewComputeAPIClientFromClient(publicapi.NewAPIClient(baseURI))
    19  }
    20  
    21  // NewComputeAPIClientFromClient returns a new client for a node's API server.
    22  func NewComputeAPIClientFromClient(baseClient *publicapi.APIClient) *ComputeAPIClient {
    23  	return &ComputeAPIClient{
    24  		APIClient: *baseClient,
    25  	}
    26  }
    27  
    28  func (apiClient *ComputeAPIClient) Debug(ctx context.Context) (map[string]model.DebugInfo, error) {
    29  	ctx, span := system.NewSpan(ctx, system.GetTracer(), "pkg/compute/publicapi.ComputeAPIClient.Debug")
    30  	defer span.End()
    31  
    32  	req := struct{}{}
    33  	var res map[string]model.DebugInfo
    34  	if err := apiClient.Post(ctx, APIPrefix+"debug", req, &res); err != nil {
    35  		return res, err
    36  	}
    37  
    38  	return res, nil
    39  }