commit progress on service
parent
03bbcc461b
commit
0a861ac68f
|
|
@ -13,7 +13,6 @@ WORKDIR /go/src/${SERVICE}
|
|||
RUN go mod tidy \
|
||||
&& CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o /opt/${SERVICE} /go/src/${SERVICE} \
|
||||
&& CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -gcflags='-N -l' -v -o /opt/${SERVICE}-debug /go/src/${SERVICE}
|
||||
# && go build -v -gcflags='all=-N -l' -o /opt/${SERVICE}-debug /go/src/${SERVICE}
|
||||
|
||||
ENTRYPOINT ['/go/bin/dlv']
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,118 @@
|
|||
-- +goose Up
|
||||
START TRANSACTION;
|
||||
|
||||
CREATE SCHEMA IF NOT EXISTS catalog;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS catalog.upcoming_auctions (
|
||||
id SERIAL PRIMARY KEY,
|
||||
fingerprint VARCHAR(512) NOT NULL UNIQUE,
|
||||
title VARCHAR(1024) NOT NULL,
|
||||
description VARCHAR(16535) NOT NULL DEFAULT '',
|
||||
startTs TIMESTAMP NOT NULL,
|
||||
endTs TIMESTAMP,
|
||||
itemCount INT NOT NULL DEFAULT 0,
|
||||
sourceSiteURL VARCHAR(1024) NOT NULL DEFAULT '',
|
||||
sourceSiteName VARCHAR(256) NOT NULL,
|
||||
sourceURL VARCHAR(1024) NOT NULL,
|
||||
country VARCHAR(64) NOT NULL,
|
||||
province VARCHAR(128) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS catalog.upcoming_auctions_fts (
|
||||
id SERIAL PRIMARY KEY,
|
||||
auctionId INT REFERENCES catalog.upcoming_auctions(id),
|
||||
title VARCHAR(1024) NOT NULL,
|
||||
description VARCHAR(16535) NOT NULL DEFAULT '',
|
||||
ts tsvector GENERATED ALWAYS AS
|
||||
(setweight(to_tsvector('english', title), 'A') ||
|
||||
setweight(to_tsvector('english', description), 'B')) STORED
|
||||
);
|
||||
|
||||
CREATE INDEX _ts_idx ON catalog.upcoming_auctions_fts USING GIN(title_ts_idx);
|
||||
CREATE INDEX description_ts_idx ON catalog.upcoming_auctions_fts USING GIN(description_ts_idx);
|
||||
|
||||
|
||||
-- +goose StatementBegin
|
||||
CREATE OR REPLACE FUNCTION bh_import_auction(
|
||||
p_fingerprint VARCHAR(512),
|
||||
p_title VARCHAR(1024),
|
||||
p_description VARCHAR(16535),
|
||||
p_startTs TIMESTAMP,
|
||||
p_endTs TIMESTAMP,
|
||||
p_itemCount INT,
|
||||
p_sourceSiteURL VARCHAR(1024),
|
||||
p_sourceSiteName VARCHAR(256),
|
||||
p_sourceURL VARCHAR(1024),
|
||||
p_country VARCHAR(64),
|
||||
p_province VARCHAR(128))
|
||||
RETURNS integer
|
||||
LANGUAGE plpgsql
|
||||
AS
|
||||
$body$
|
||||
DECLARE
|
||||
p_auctionId catalog.upcoming_auctions.id%TYPE;
|
||||
BEGIN
|
||||
INSERT INTO catalog.upcoming_auctions (
|
||||
fingerprint,
|
||||
title,
|
||||
description,
|
||||
startTs,
|
||||
endTs,
|
||||
itemCount,
|
||||
sourceSiteURL,
|
||||
sourceSiteName,
|
||||
sourceURL,
|
||||
country,
|
||||
province
|
||||
) VALUES (
|
||||
p_fingerprint,
|
||||
p_title,
|
||||
p_description,
|
||||
p_startTs,
|
||||
p_endTs,
|
||||
p_itemCount,
|
||||
p_sourceSiteURL,
|
||||
p_sourceSiteName,
|
||||
p_sourceURL,
|
||||
p_country,
|
||||
p_province
|
||||
) RETURNING id INTO p_auctionId;
|
||||
|
||||
INSERT INTO catalog.upcoming_auctions_fts (
|
||||
auctionId,
|
||||
title,
|
||||
description
|
||||
) VALUES (
|
||||
p_auctionId,
|
||||
p_title,
|
||||
p_description
|
||||
);
|
||||
|
||||
RETURN p_auctionId;
|
||||
|
||||
$body$
|
||||
VOLATILE;
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose StatementBegin
|
||||
DO
|
||||
$do$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT FROM pg_catalog.pg_roles -- SELECT list can be empty for this
|
||||
WHERE rolname = 'catalog-service') THEN
|
||||
|
||||
CREATE USER "catalog-service" WITH PASSWORD 'catalog-service';
|
||||
END IF;
|
||||
END
|
||||
$do$;
|
||||
-- +goose StatementEnd
|
||||
|
||||
GRANT CONNECT ON DATABASE bh to "catalog-service";
|
||||
GRANT USAGE ON SCHEMA catalog TO "catalog-service";
|
||||
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA catalog TO "catalog-service";
|
||||
GRANT SELECT, INSERT, UPDATE ON ALL TABLES IN SCHEMA catalog TO "catalog-service";
|
||||
|
||||
COMMIT;
|
||||
|
||||
-- +goose Down
|
||||
|
|
@ -3,7 +3,6 @@ package data
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.vdhsn.com/barretthousen/barretthousen/src/catalog/internal/data/postgres"
|
||||
"git.vdhsn.com/barretthousen/barretthousen/src/lib/domain/catalog"
|
||||
|
|
@ -13,12 +12,7 @@ type PGCatalogStorage struct {
|
|||
Queries *postgres.Queries
|
||||
}
|
||||
|
||||
type UpcomingQuery struct {
|
||||
Term string
|
||||
StartDateFilter time.Time
|
||||
}
|
||||
|
||||
func (ps *PGCatalogStorage) GetUpcoming(ctx context.Context, q UpcomingQuery) (results []catalog.Auction, total int, err error) {
|
||||
func (ps *PGCatalogStorage) GetUpcoming(ctx context.Context, q catalog.UpcomingQuery) (results []catalog.Auction, total int, err error) {
|
||||
var pgResults []postgres.CatalogUpcomingAuction
|
||||
|
||||
if pgResults, err = ps.Queries.GetUpcoming(ctx, postgres.GetUpcomingParams{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"git.vdhsn.com/barretthousen/barretthousen/src/catalog/api"
|
||||
"git.vdhsn.com/barretthousen/barretthousen/src/lib/domain/catalog"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
func NewCatalogServer(d *catalog.Domain) func(grpcServer grpc.ServiceRegistrar, endpoint string) {
|
||||
return func(grpcServer grpc.ServiceRegistrar, endpoint string) {
|
||||
api.RegisterCatalogServer(grpcServer, &catalogHandler{domain: d})
|
||||
}
|
||||
}
|
||||
|
||||
type catalogHandler struct {
|
||||
api.UnimplementedCatalogServer
|
||||
domain *catalog.Domain
|
||||
}
|
||||
|
||||
func (rh *catalogHandler) GetUpcoming(ctx context.Context, cmd *api.AuctionSearchCriteria) (r *api.GetUpcomingResult, err error) {
|
||||
err = errors.New("Unimplemented")
|
||||
return
|
||||
}
|
||||
|
||||
func (rh *catalogHandler) ImportAuction(ctx context.Context, cmd *api.ImportAuctionMessage) (r *api.AuctionCreated, err error) {
|
||||
err = errors.New("Unimplemented")
|
||||
return
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"flag"
|
||||
"fmt"
|
||||
|
||||
"git.vdhsn.com/barretthousen/barretthousen/src/catalog/internal"
|
||||
"git.vdhsn.com/barretthousen/barretthousen/src/catalog/internal/data"
|
||||
"git.vdhsn.com/barretthousen/barretthousen/src/catalog/internal/data/postgres"
|
||||
"git.vdhsn.com/barretthousen/barretthousen/src/lib/domain/catalog"
|
||||
|
|
|
|||
Loading…
Reference in New Issue