logs-analyzer/signoz/pkg/query-service/dao/sqlite/ingestion.go

40 lines
938 B
Go
Raw Permalink Normal View History

2024-09-02 22:47:30 +03:00
package sqlite
import (
"context"
"go.signoz.io/signoz/pkg/query-service/model"
)
func (mds *ModelDaoSqlite) GetIngestionKeys(ctx context.Context) ([]model.IngestionKey, *model.ApiError) {
ingestion_keys := []model.IngestionKey{}
err := mds.db.Select(&ingestion_keys, `SELECT * FROM ingestion_keys`)
if err != nil {
return nil, &model.ApiError{Typ: model.ErrorInternal, Err: err}
}
return ingestion_keys, nil
}
func (mds *ModelDaoSqlite) InsertIngestionKey(ctx context.Context, ingestion_key *model.IngestionKey) *model.ApiError {
_, err := mds.db.ExecContext(ctx, `
INSERT INTO ingestion_keys (
ingestion_key,
name,
key_id,
ingestion_url,
data_region
) VALUES (
?,
?,
?,
?,
?
)`, ingestion_key.IngestionKey, ingestion_key.Name, ingestion_key.KeyId, ingestion_key.IngestionURL, ingestion_key.DataRegion)
if err != nil {
return &model.ApiError{Typ: model.ErrorInternal, Err: err}
}
return nil
}