Skip to content

Commit

Permalink
chore: review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
achettyiitr committed Dec 3, 2024
1 parent 7857e5e commit 861991a
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func mustRead(r io.Reader) []byte {
return data
}

// CreateChannel creates a new channel with the given request.
func (a *API) CreateChannel(ctx context.Context, channelReq *model.CreateChannelRequest) (*model.ChannelResponse, error) {
reqJSON, err := json.Marshal(channelReq)
if err != nil {
Expand Down Expand Up @@ -72,6 +73,9 @@ func (a *API) CreateChannel(ctx context.Context, channelReq *model.CreateChannel
return &res, nil
}

// DeleteChannel deletes the channel with the given ID.
// If sync is true, the server waits for the flushing of all records in the channel, then do the soft delete.
// If sync is false, the server do the soft delete immediately and we need to wait for the flushing of all records.
func (a *API) DeleteChannel(ctx context.Context, channelID string, sync bool) error {
deleteChannelURL := a.clientURL + "/channels/" + channelID
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, deleteChannelURL, nil)
Expand All @@ -98,6 +102,7 @@ func (a *API) DeleteChannel(ctx context.Context, channelID string, sync bool) er
}
}

// GetChannel retrieves the channel with the given ID.
func (a *API) GetChannel(ctx context.Context, channelID string) (*model.ChannelResponse, error) {
getChannelURL := a.clientURL + "/channels/" + channelID
req, err := http.NewRequestWithContext(ctx, http.MethodGet, getChannelURL, nil)
Expand All @@ -123,6 +128,7 @@ func (a *API) GetChannel(ctx context.Context, channelID string) (*model.ChannelR
return &res, nil
}

// Insert inserts the given rows into the channel with the given ID.
func (a *API) Insert(ctx context.Context, channelID string, insertRequest *model.InsertRequest) (*model.InsertResponse, error) {
reqJSON, err := json.Marshal(insertRequest)
if err != nil {
Expand Down Expand Up @@ -153,6 +159,7 @@ func (a *API) Insert(ctx context.Context, channelID string, insertRequest *model
return &res, nil
}

// GetStatus retrieves the status of the channel with the given ID.
func (a *API) GetStatus(ctx context.Context, channelID string) (*model.StatusResponse, error) {
statusURL := a.clientURL + "/channels/" + channelID + "/status"
req, err := http.NewRequestWithContext(ctx, http.MethodGet, statusURL, nil)
Expand Down

0 comments on commit 861991a

Please sign in to comment.