Skip to content

Commit

Permalink
Merge pull request #18 from Photoroom/ben/datago_dataroom_client
Browse files Browse the repository at this point in the history
[Refactor] Remove references to Dataroom in the types
  • Loading branch information
blefaudeux authored Oct 6, 2024
2 parents e920ff7 + 86c1e70 commit dd80544
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/pkg/client/backend_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

type BackendHTTP struct {
config *DataroomClientConfig
config *DatagoConfig
}

func (b BackendHTTP) collectSamples(chanSampleMetadata chan dbSampleMetadata, chanSamples chan Sample, transform *ARAwareTransform) {
Expand Down
22 changes: 11 additions & 11 deletions src/pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const (
// incoming: object storage
)

type DataroomClientConfig struct {
type DatagoConfig struct {
Sources string
SourceType DatagoSourceType
RequireImages bool
Expand All @@ -86,7 +86,7 @@ type DataroomClientConfig struct {
PageSize int
}

type DataroomClient struct {
type DatagoClient struct {
concurrency int
baseRequest http.Request

Expand Down Expand Up @@ -138,8 +138,8 @@ type Backend interface {

// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

func GetDefaultConfig() DataroomClientConfig {
return DataroomClientConfig{
func GetDefaultConfig() DatagoConfig {
return DatagoConfig{
Sources: "",
SourceType: SourceTypeDB,
RequireImages: true,
Expand Down Expand Up @@ -168,7 +168,7 @@ func GetDefaultConfig() DataroomClientConfig {
}

// Create a new Dataroom Client
func GetClient(config DataroomClientConfig) *DataroomClient {
func GetClient(config DatagoConfig) *DatagoClient {

// Create the frontend and backend
var frontend Frontend
Expand All @@ -183,7 +183,7 @@ func GetClient(config DataroomClientConfig) *DataroomClient {
}

// Create the client
client := &DataroomClient{
client := &DatagoClient{
concurrency: config.ConcurrentDownloads,
chanPageResults: make(chan dbResponse, 2),
chanSampleMetadata: make(chan dbSampleMetadata, config.PrefetchBufferSize),
Expand All @@ -209,15 +209,15 @@ func GetClient(config DataroomClientConfig) *DataroomClient {
}

// Make sure that the client will be Stopped() upon destruction
runtime.SetFinalizer(client, func(r *DataroomClient) {
runtime.SetFinalizer(client, func(r *DatagoClient) {
r.Stop()
})

return client
}

// Start the background downloads, make it ready to serve samples. Will grow the memory and CPU footprint
func (c *DataroomClient) Start() {
func (c *DatagoClient) Start() {
if c.context == nil || c.cancel == nil {
// Get a context and a cancel function to stop the background goroutines and gracefully handle
// interruptions at during http round trips
Expand Down Expand Up @@ -279,7 +279,7 @@ func (c *DataroomClient) Start() {
}

// Get a deserialized sample from the client
func (c *DataroomClient) GetSample() Sample {
func (c *DatagoClient) GetSample() Sample {
if c.cancel == nil {
fmt.Println("Dataroom client not started. Starting it on the first sample, this adds some initial latency")
fmt.Println("Please consider starting the client in anticipation by calling .Start()")
Expand All @@ -294,7 +294,7 @@ func (c *DataroomClient) GetSample() Sample {
}

// Stop the background downloads, will clear the memory and CPU footprint
func (c *DataroomClient) Stop() {
func (c *DatagoClient) Stop() {
fmt.Println("Stopping the dataroom client")

// Signal the coroutines that next round should be a stop
Expand All @@ -321,7 +321,7 @@ func (c *DataroomClient) Stop() {
// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Coroutines which will be running in the background

func (c *DataroomClient) asyncDispatch() {
func (c *DatagoClient) asyncDispatch() {
// Break down the page results and maintain a list of individual items to be processed

for {
Expand Down
4 changes: 2 additions & 2 deletions src/pkg/client/frontend_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type dbRequest struct {
lacksLatents string
}

func (c *DataroomClientConfig) getDbRequest() dbRequest {
func (c *DatagoConfig) getDbRequest() dbRequest {

fields := "attributes,image_direct_url"
if c.HasLatents != "" || c.HasMasks != "" {
Expand Down Expand Up @@ -101,7 +101,7 @@ type datagoFrontendDB struct {
baseRequest http.Request
}

func newDatagoFrontendDB(config DataroomClientConfig) datagoFrontendDB {
func newDatagoFrontendDB(config DatagoConfig) datagoFrontendDB {
// Define the base request once and for all
request := config.getDbRequest()

Expand Down
2 changes: 1 addition & 1 deletion src/pkg/client/serdes.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func fetchImage(client *http.Client, url string, retries int, transform *ARAware
return nil, -1., err_report
}

func fetchSample(config *DataroomClientConfig, http_client *http.Client, sample_result dbSampleMetadata, transform *ARAwareTransform) *Sample {
func fetchSample(config *DatagoConfig, http_client *http.Client, sample_result dbSampleMetadata, transform *ARAwareTransform) *Sample {
// Per sample work:
// - fetch the raw payloads
// - deserialize / decode, depending on the types
Expand Down

0 comments on commit dd80544

Please sign in to comment.