2021-05-22 13:35:30 +05:30
|
|
|
package druidReader
|
|
|
|
|
|
|
|
|
|
import (
|
2021-05-22 19:51:56 +05:30
|
|
|
"context"
|
|
|
|
|
|
2021-05-22 13:35:30 +05:30
|
|
|
"go.signoz.io/query-service/druidQuery"
|
2021-05-22 19:51:56 +05:30
|
|
|
"go.signoz.io/query-service/godruid"
|
2021-05-22 13:35:30 +05:30
|
|
|
"go.signoz.io/query-service/model"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type DruidReader struct {
|
2021-05-22 19:51:56 +05:30
|
|
|
Client *godruid.Client
|
|
|
|
|
SqlClient *druidQuery.SqlClient
|
2021-05-22 13:35:30 +05:30
|
|
|
}
|
|
|
|
|
|
2021-05-22 19:51:56 +05:30
|
|
|
func NewReader(druidClientUrl string) *DruidReader {
|
|
|
|
|
|
2021-05-22 13:35:30 +05:30
|
|
|
initialize()
|
2021-05-22 19:51:56 +05:30
|
|
|
|
|
|
|
|
client := godruid.Client{
|
|
|
|
|
Url: druidClientUrl,
|
|
|
|
|
Debug: true,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sqlClient := druidQuery.SqlClient{
|
|
|
|
|
Url: druidClientUrl,
|
|
|
|
|
Debug: true,
|
|
|
|
|
}
|
|
|
|
|
return &DruidReader{
|
|
|
|
|
Client: &client,
|
|
|
|
|
SqlClient: &sqlClient,
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-22 13:35:30 +05:30
|
|
|
}
|
|
|
|
|
func initialize() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-22 19:51:56 +05:30
|
|
|
func (druid *DruidReader) GetServiceOverview(ctx context.Context, query *model.GetServiceOverviewParams) (*[]model.ServiceOverviewItem, error) {
|
|
|
|
|
return druidQuery.GetServiceOverview(druid.SqlClient, query)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (druid *DruidReader) GetServices(ctx context.Context, query *model.GetServicesParams) (*[]model.ServiceItem, error) {
|
|
|
|
|
return druidQuery.GetServices(druid.SqlClient, query)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (druid *DruidReader) GetApplicationPercentiles(ctx context.Context, query *model.ApplicationPercentileParams) ([]godruid.Timeseries, error) {
|
|
|
|
|
return druidQuery.GetApplicationPercentiles(druid.Client, query)
|
2021-05-22 13:35:30 +05:30
|
|
|
}
|