From efccea3f64636e1b69aa02352c965170c02f620b Mon Sep 17 00:00:00 2001 From: Arnaud Delcasse Date: Wed, 8 Oct 2025 09:09:53 +0200 Subject: [PATCH] initial commit --- Dockerfile | 28 + config.go | 44 + core/service/service.go | 246 +++++ data/storage/mock.go | 124 +++ data/storage/mongodb.go | 219 ++++ data/storage/storage.go | 28 + data/storage/storage_factory.go | 20 + data/types/saved_search.go | 19 + go.mod | 49 + go.sum | 187 ++++ main.go | 48 + servers/grpc/proto/gen/saved-search.pb.go | 985 ++++++++++++++++++ .../grpc/proto/gen/saved-search_grpc.pb.go | 323 ++++++ servers/grpc/proto/saved-search.proto | 112 ++ servers/grpc/server/server.go | 232 +++++ servers/grpc/transformers/transformers.go | 116 +++ 16 files changed, 2780 insertions(+) create mode 100644 Dockerfile create mode 100644 config.go create mode 100644 core/service/service.go create mode 100644 data/storage/mock.go create mode 100644 data/storage/mongodb.go create mode 100644 data/storage/storage.go create mode 100644 data/storage/storage_factory.go create mode 100644 data/types/saved_search.go create mode 100644 go.mod create mode 100644 go.sum create mode 100644 main.go create mode 100644 servers/grpc/proto/gen/saved-search.pb.go create mode 100644 servers/grpc/proto/gen/saved-search_grpc.pb.go create mode 100644 servers/grpc/proto/saved-search.proto create mode 100644 servers/grpc/server/server.go create mode 100644 servers/grpc/transformers/transformers.go diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4f353e0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM golang:1.22-alpine AS builder + +WORKDIR /app + +# Copy go mod files +COPY go.mod go.sum ./ + +# Download dependencies +RUN go mod download + +# Copy source code +COPY . . + +# Build the application +RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main . + +FROM alpine:latest + +RUN apk --no-cache add ca-certificates + +WORKDIR /root/ + +# Copy the binary from builder +COPY --from=builder /app/main . + +EXPOSE 8080 + +CMD ["./main"] \ No newline at end of file diff --git a/config.go b/config.go new file mode 100644 index 0000000..2463c25 --- /dev/null +++ b/config.go @@ -0,0 +1,44 @@ +package main + +import ( + "strings" + + "github.com/spf13/viper" +) + +func ReadConfig() (*viper.Viper, error) { + defaults := map[string]any{ + "name": "COOPGO Saved Search Service", + "dev_env": false, + "storage": map[string]any{ + "db": map[string]any{ + "type": "mongodb", + "mongodb": map[string]any{ + "host": "localhost", + "port": 27017, + "db_name": "coopgo_platform", + "collections": map[string]any{ + "saved_searches": "saved_searches", + }, + }, + }, + }, + "services": map[string]any{ + "grpc": map[string]any{ + "enable": true, + "port": 8080, + }, + }, + } + + v := viper.New() + for key, value := range defaults { + v.SetDefault(key, value) + } + v.SetConfigName("config") + v.AddConfigPath(".") + v.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) + v.AutomaticEnv() + err := v.ReadInConfig() + return v, err +} \ No newline at end of file diff --git a/core/service/service.go b/core/service/service.go new file mode 100644 index 0000000..aa181e7 --- /dev/null +++ b/core/service/service.go @@ -0,0 +1,246 @@ +package service + +import ( + "context" + "fmt" + "time" + + "git.coopgo.io/coopgo-platform/saved-search/data/storage" + "git.coopgo.io/coopgo-platform/saved-search/data/types" + "github.com/google/uuid" + "github.com/paulmach/orb/geojson" + "github.com/rs/zerolog/log" +) + +// SavedSearchService handles the business logic for saved searches +type SavedSearchService struct { + storage storage.Storage +} + +// NewSavedSearchService creates a new SavedSearchService instance +func NewSavedSearchService(storage storage.Storage) *SavedSearchService { + return &SavedSearchService{ + storage: storage, + } +} + +// CreateSavedSearchParams represents the parameters for creating a saved search +type CreateSavedSearchParams struct { + OwnerID string `json:"owner_id"` + Departure *geojson.Feature `json:"departure"` + Destination *geojson.Feature `json:"destination"` + DateTime time.Time `json:"datetime"` + Data map[string]interface{} `json:"data"` +} + +// UpdateSavedSearchParams represents the parameters for updating a saved search +type UpdateSavedSearchParams struct { + ID string `json:"id"` + OwnerID string `json:"owner_id"` + Departure *geojson.Feature `json:"departure"` + Destination *geojson.Feature `json:"destination"` + DateTime time.Time `json:"datetime"` + Data map[string]interface{} `json:"data"` +} + +// ListSavedSearchesParams represents the parameters for listing saved searches +type ListSavedSearchesParams struct { + OwnerID string `json:"owner_id"` + Limit int `json:"limit"` + Offset int `json:"offset"` +} + +// ListSavedSearchesResult represents the result of listing saved searches +type ListSavedSearchesResult struct { + SavedSearches []*types.SavedSearch `json:"saved_searches"` + Total int64 `json:"total"` + Limit int `json:"limit"` + Offset int `json:"offset"` +} + +// CreateSavedSearch creates a new saved search +func (s *SavedSearchService) CreateSavedSearch(ctx context.Context, params CreateSavedSearchParams) (*types.SavedSearch, error) { + // Validate required fields + if params.OwnerID == "" { + return nil, fmt.Errorf("owner_id is required") + } + + if params.Departure == nil { + return nil, fmt.Errorf("departure is required") + } + + if params.Destination == nil { + return nil, fmt.Errorf("destination is required") + } + + if params.DateTime.IsZero() { + return nil, fmt.Errorf("datetime is required") + } + + // Ensure data is not nil + if params.Data == nil { + params.Data = make(map[string]interface{}) + } + + // Create saved search + search := types.SavedSearch{ + ID: uuid.NewString(), + OwnerID: params.OwnerID, + Departure: params.Departure, + Destination: params.Destination, + DateTime: params.DateTime, + Data: params.Data, + } + + if err := s.storage.CreateSavedSearch(ctx, search); err != nil { + log.Error().Err(err).Str("owner_id", params.OwnerID).Msg("failed to create saved search") + return nil, fmt.Errorf("failed to create saved search: %w", err) + } + + log.Info().Str("id", search.ID).Str("owner_id", search.OwnerID).Msg("saved search created successfully") + return &search, nil +} + +// GetSavedSearch retrieves a saved search by ID +func (s *SavedSearchService) GetSavedSearch(ctx context.Context, id string) (*types.SavedSearch, error) { + if id == "" { + return nil, fmt.Errorf("id is required") + } + + search, err := s.storage.GetSavedSearch(ctx, id) + if err != nil { + log.Error().Err(err).Str("id", id).Msg("failed to get saved search") + return nil, fmt.Errorf("failed to get saved search: %w", err) + } + + return search, nil +} + +// GetSavedSearchesByOwner retrieves all saved searches for a specific owner +func (s *SavedSearchService) GetSavedSearchesByOwner(ctx context.Context, ownerID string) ([]*types.SavedSearch, error) { + if ownerID == "" { + return nil, fmt.Errorf("owner_id is required") + } + + searches, err := s.storage.GetSavedSearchesByOwner(ctx, ownerID) + if err != nil { + log.Error().Err(err).Str("owner_id", ownerID).Msg("failed to get saved searches by owner") + return nil, fmt.Errorf("failed to get saved searches: %w", err) + } + + return searches, nil +} + +// UpdateSavedSearch updates an existing saved search +func (s *SavedSearchService) UpdateSavedSearch(ctx context.Context, params UpdateSavedSearchParams) (*types.SavedSearch, error) { + // Validate required fields + if params.ID == "" { + return nil, fmt.Errorf("id is required") + } + + if params.OwnerID == "" { + return nil, fmt.Errorf("owner_id is required") + } + + if params.Departure == nil { + return nil, fmt.Errorf("departure is required") + } + + if params.Destination == nil { + return nil, fmt.Errorf("destination is required") + } + + if params.DateTime.IsZero() { + return nil, fmt.Errorf("datetime is required") + } + + // Check if the saved search exists and belongs to the owner + existing, err := s.storage.GetSavedSearch(ctx, params.ID) + if err != nil { + return nil, fmt.Errorf("saved search not found: %w", err) + } + + if existing.OwnerID != params.OwnerID { + return nil, fmt.Errorf("access denied: saved search belongs to different owner") + } + + // Ensure data is not nil + if params.Data == nil { + params.Data = make(map[string]interface{}) + } + + // Update saved search + search := types.SavedSearch{ + ID: params.ID, + OwnerID: params.OwnerID, + Departure: params.Departure, + Destination: params.Destination, + DateTime: params.DateTime, + Data: params.Data, + CreatedAt: existing.CreatedAt, // Preserve creation time + } + + if err := s.storage.UpdateSavedSearch(ctx, search); err != nil { + log.Error().Err(err).Str("id", params.ID).Msg("failed to update saved search") + return nil, fmt.Errorf("failed to update saved search: %w", err) + } + + log.Info().Str("id", search.ID).Str("owner_id", search.OwnerID).Msg("saved search updated successfully") + return &search, nil +} + +// DeleteSavedSearch deletes a saved search by ID, with owner verification +func (s *SavedSearchService) DeleteSavedSearch(ctx context.Context, id, ownerID string) error { + if id == "" { + return fmt.Errorf("id is required") + } + + if ownerID == "" { + return fmt.Errorf("owner_id is required") + } + + // Check if the saved search exists and belongs to the owner + existing, err := s.storage.GetSavedSearch(ctx, id) + if err != nil { + return fmt.Errorf("saved search not found: %w", err) + } + + if existing.OwnerID != ownerID { + return fmt.Errorf("access denied: saved search belongs to different owner") + } + + if err := s.storage.DeleteSavedSearch(ctx, id); err != nil { + log.Error().Err(err).Str("id", id).Msg("failed to delete saved search") + return fmt.Errorf("failed to delete saved search: %w", err) + } + + log.Info().Str("id", id).Str("owner_id", ownerID).Msg("saved search deleted successfully") + return nil +} + +// ListSavedSearches retrieves paginated saved searches with optional filtering +func (s *SavedSearchService) ListSavedSearches(ctx context.Context, params ListSavedSearchesParams) (*ListSavedSearchesResult, error) { + // Set default pagination values + if params.Limit <= 0 { + params.Limit = 10 + } + if params.Limit > 100 { + params.Limit = 100 // Max limit + } + if params.Offset < 0 { + params.Offset = 0 + } + + searches, total, err := s.storage.ListSavedSearches(ctx, params.OwnerID, params.Limit, params.Offset) + if err != nil { + log.Error().Err(err).Str("owner_id", params.OwnerID).Msg("failed to list saved searches") + return nil, fmt.Errorf("failed to list saved searches: %w", err) + } + + return &ListSavedSearchesResult{ + SavedSearches: searches, + Total: total, + Limit: params.Limit, + Offset: params.Offset, + }, nil +} \ No newline at end of file diff --git a/data/storage/mock.go b/data/storage/mock.go new file mode 100644 index 0000000..383894f --- /dev/null +++ b/data/storage/mock.go @@ -0,0 +1,124 @@ +package storage + +import ( + "context" + "fmt" + "sync" + "time" + + "git.coopgo.io/coopgo-platform/saved-search/data/types" +) + +// MockStorage implements Storage interface for testing +type MockStorage struct { + mu sync.RWMutex + data map[string]*types.SavedSearch + counter int +} + +// NewMockStorage creates a new mock storage instance +func NewMockStorage() *MockStorage { + return &MockStorage{ + data: make(map[string]*types.SavedSearch), + } +} + +func (m *MockStorage) CreateSavedSearch(ctx context.Context, search types.SavedSearch) error { + m.mu.Lock() + defer m.mu.Unlock() + + now := time.Now() + search.CreatedAt = now + search.UpdatedAt = now + + m.data[search.ID] = &search + m.counter++ + + return nil +} + +func (m *MockStorage) GetSavedSearch(ctx context.Context, id string) (*types.SavedSearch, error) { + m.mu.RLock() + defer m.mu.RUnlock() + + search, exists := m.data[id] + if !exists { + return nil, fmt.Errorf("saved search not found") + } + + // Return a copy to avoid mutation issues + searchCopy := *search + return &searchCopy, nil +} + +func (m *MockStorage) GetSavedSearchesByOwner(ctx context.Context, ownerID string) ([]*types.SavedSearch, error) { + m.mu.RLock() + defer m.mu.RUnlock() + + var searches []*types.SavedSearch + for _, search := range m.data { + if search.OwnerID == ownerID { + searchCopy := *search + searches = append(searches, &searchCopy) + } + } + + return searches, nil +} + +func (m *MockStorage) UpdateSavedSearch(ctx context.Context, search types.SavedSearch) error { + m.mu.Lock() + defer m.mu.Unlock() + + existing, exists := m.data[search.ID] + if !exists { + return fmt.Errorf("saved search not found") + } + + search.CreatedAt = existing.CreatedAt // Preserve creation time + search.UpdatedAt = time.Now() + m.data[search.ID] = &search + + return nil +} + +func (m *MockStorage) DeleteSavedSearch(ctx context.Context, id string) error { + m.mu.Lock() + defer m.mu.Unlock() + + if _, exists := m.data[id]; !exists { + return fmt.Errorf("saved search not found") + } + + delete(m.data, id) + return nil +} + +func (m *MockStorage) ListSavedSearches(ctx context.Context, ownerID string, limit, offset int) ([]*types.SavedSearch, int64, error) { + m.mu.RLock() + defer m.mu.RUnlock() + + var allSearches []*types.SavedSearch + for _, search := range m.data { + if ownerID == "" || search.OwnerID == ownerID { + searchCopy := *search + allSearches = append(allSearches, &searchCopy) + } + } + + total := int64(len(allSearches)) + + // Apply pagination + start := offset + end := offset + limit + + if start > len(allSearches) { + return []*types.SavedSearch{}, total, nil + } + + if end > len(allSearches) { + end = len(allSearches) + } + + return allSearches[start:end], total, nil +} \ No newline at end of file diff --git a/data/storage/mongodb.go b/data/storage/mongodb.go new file mode 100644 index 0000000..1f41eb8 --- /dev/null +++ b/data/storage/mongodb.go @@ -0,0 +1,219 @@ +package storage + +import ( + "context" + "fmt" + "time" + + "git.coopgo.io/coopgo-platform/saved-search/data/types" + "github.com/rs/zerolog/log" + "github.com/spf13/viper" + "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/mongo/options" +) + +// MongoDBStorage implements Storage interface using MongoDB +type MongoDBStorage struct { + client *mongo.Client + database string + collection string +} + +// NewMongoDBStorage creates a new MongoDB storage instance +func NewMongoDBStorage(client *mongo.Client, database, collection string) (*MongoDBStorage, error) { + storage := &MongoDBStorage{ + client: client, + database: database, + collection: collection, + } + + // Create indexes + if err := storage.createIndexes(); err != nil { + return nil, fmt.Errorf("failed to create indexes: %w", err) + } + + return storage, nil +} + +// NewMongoDBStorageFromConfig creates a new MongoDB storage from config following solidarity transport pattern +func NewMongoDBStorageFromConfig(cfg *viper.Viper) (Storage, error) { + var ( + mongodb_uri = cfg.GetString("storage.db.mongodb.uri") + mongodb_host = cfg.GetString("storage.db.mongodb.host") + mongodb_port = cfg.GetString("storage.db.mongodb.port") + mongodb_dbname = cfg.GetString("storage.db.mongodb.db_name") + mongodb_collection = cfg.GetString("storage.db.mongodb.collections.saved_searches") + ) + + if mongodb_uri == "" { + mongodb_uri = fmt.Sprintf("mongodb://%s:%s/%s", mongodb_host, mongodb_port, mongodb_dbname) + } + + client, err := mongo.Connect(context.Background(), options.Client().ApplyURI(mongodb_uri)) + if err != nil { + return nil, err + } + + log.Info().Str("collection", mongodb_collection).Msg("mongodb storage initialized") + + return NewMongoDBStorage(client, mongodb_dbname, mongodb_collection) +} + +func (s *MongoDBStorage) createIndexes() error { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + + coll := s.client.Database(s.database).Collection(s.collection) + + // Create index on owner_id for efficient querying + ownerIndex := mongo.IndexModel{ + Keys: bson.D{{Key: "owner_id", Value: 1}}, + } + + // Create compound index on owner_id and created_at for pagination + paginationIndex := mongo.IndexModel{ + Keys: bson.D{{Key: "owner_id", Value: 1}, {Key: "created_at", Value: -1}}, + } + + _, err := coll.Indexes().CreateMany(ctx, []mongo.IndexModel{ownerIndex, paginationIndex}) + return err +} + +func (s *MongoDBStorage) CreateSavedSearch(ctx context.Context, search types.SavedSearch) error { + coll := s.client.Database(s.database).Collection(s.collection) + + now := time.Now() + search.CreatedAt = now + search.UpdatedAt = now + + _, err := coll.InsertOne(ctx, search) + if err != nil { + log.Error().Err(err).Msg("CreateSavedSearch error") + return fmt.Errorf("failed to create saved search: %w", err) + } + + return nil +} + +func (s *MongoDBStorage) GetSavedSearch(ctx context.Context, id string) (*types.SavedSearch, error) { + coll := s.client.Database(s.database).Collection(s.collection) + + var search types.SavedSearch + err := coll.FindOne(ctx, bson.M{"_id": id}).Decode(&search) + if err != nil { + if err == mongo.ErrNoDocuments { + return nil, fmt.Errorf("saved search not found") + } + log.Error().Err(err).Msg("GetSavedSearch error") + return nil, fmt.Errorf("failed to get saved search: %w", err) + } + + return &search, nil +} + +func (s *MongoDBStorage) GetSavedSearchesByOwner(ctx context.Context, ownerID string) ([]*types.SavedSearch, error) { + coll := s.client.Database(s.database).Collection(s.collection) + + // Filter to only include future searches + filter := bson.M{ + "owner_id": ownerID, + "datetime": bson.M{"$gt": time.Now()}, + } + cursor, err := coll.Find(ctx, filter) + if err != nil { + log.Error().Err(err).Msg("GetSavedSearchesByOwner error") + return nil, fmt.Errorf("failed to get saved searches: %w", err) + } + defer cursor.Close(ctx) + + var searches []*types.SavedSearch + for cursor.Next(ctx) { + var search types.SavedSearch + if err := cursor.Decode(&search); err != nil { + log.Error().Err(err).Msg("decode saved search error") + continue + } + searches = append(searches, &search) + } + + return searches, nil +} + +func (s *MongoDBStorage) UpdateSavedSearch(ctx context.Context, search types.SavedSearch) error { + coll := s.client.Database(s.database).Collection(s.collection) + + search.UpdatedAt = time.Now() + + filter := bson.M{"_id": search.ID} + update := bson.M{"$set": search} + + result, err := coll.UpdateOne(ctx, filter, update) + if err != nil { + log.Error().Err(err).Msg("UpdateSavedSearch error") + return fmt.Errorf("failed to update saved search: %w", err) + } + + if result.MatchedCount == 0 { + return fmt.Errorf("saved search not found") + } + + return nil +} + +func (s *MongoDBStorage) DeleteSavedSearch(ctx context.Context, id string) error { + coll := s.client.Database(s.database).Collection(s.collection) + + result, err := coll.DeleteOne(ctx, bson.M{"_id": id}) + if err != nil { + log.Error().Err(err).Msg("DeleteSavedSearch error") + return fmt.Errorf("failed to delete saved search: %w", err) + } + + if result.DeletedCount == 0 { + return fmt.Errorf("saved search not found") + } + + return nil +} + +func (s *MongoDBStorage) ListSavedSearches(ctx context.Context, ownerID string, limit, offset int) ([]*types.SavedSearch, int64, error) { + coll := s.client.Database(s.database).Collection(s.collection) + + filter := bson.M{} + if ownerID != "" { + filter["owner_id"] = ownerID + } + + // Get total count + total, err := coll.CountDocuments(ctx, filter) + if err != nil { + log.Error().Err(err).Msg("ListSavedSearches count error") + return nil, 0, fmt.Errorf("failed to count saved searches: %w", err) + } + + // Get paginated results + opts := options.Find(). + SetSort(bson.D{{Key: "created_at", Value: -1}}). + SetLimit(int64(limit)). + SetSkip(int64(offset)) + + cursor, err := coll.Find(ctx, filter, opts) + if err != nil { + log.Error().Err(err).Msg("ListSavedSearches find error") + return nil, 0, fmt.Errorf("failed to list saved searches: %w", err) + } + defer cursor.Close(ctx) + + var searches []*types.SavedSearch + for cursor.Next(ctx) { + var search types.SavedSearch + if err := cursor.Decode(&search); err != nil { + log.Error().Err(err).Msg("decode saved search error") + continue + } + searches = append(searches, &search) + } + + return searches, total, nil +} \ No newline at end of file diff --git a/data/storage/storage.go b/data/storage/storage.go new file mode 100644 index 0000000..d8dbeb1 --- /dev/null +++ b/data/storage/storage.go @@ -0,0 +1,28 @@ +package storage + +import ( + "context" + + "git.coopgo.io/coopgo-platform/saved-search/data/types" +) + +// Storage interface defines the methods for saved search storage +type Storage interface { + // CreateSavedSearch creates a new saved search + CreateSavedSearch(ctx context.Context, search types.SavedSearch) error + + // GetSavedSearch retrieves a saved search by ID + GetSavedSearch(ctx context.Context, id string) (*types.SavedSearch, error) + + // GetSavedSearchesByOwner retrieves all saved searches for a specific owner + GetSavedSearchesByOwner(ctx context.Context, ownerID string) ([]*types.SavedSearch, error) + + // UpdateSavedSearch updates an existing saved search + UpdateSavedSearch(ctx context.Context, search types.SavedSearch) error + + // DeleteSavedSearch deletes a saved search by ID + DeleteSavedSearch(ctx context.Context, id string) error + + // ListSavedSearches retrieves paginated saved searches with optional filtering + ListSavedSearches(ctx context.Context, ownerID string, limit, offset int) ([]*types.SavedSearch, int64, error) +} \ No newline at end of file diff --git a/data/storage/storage_factory.go b/data/storage/storage_factory.go new file mode 100644 index 0000000..592827a --- /dev/null +++ b/data/storage/storage_factory.go @@ -0,0 +1,20 @@ +package storage + +import ( + "fmt" + + "github.com/spf13/viper" +) + +func NewStorage(cfg *viper.Viper) (Storage, error) { + storage_type := cfg.GetString("storage.db.type") + + switch storage_type { + case "mongodb": + return NewMongoDBStorageFromConfig(cfg) + case "mock": + return NewMockStorage(), nil + default: + return nil, fmt.Errorf("storage type %v is not supported", storage_type) + } +} \ No newline at end of file diff --git a/data/types/saved_search.go b/data/types/saved_search.go new file mode 100644 index 0000000..d7f6595 --- /dev/null +++ b/data/types/saved_search.go @@ -0,0 +1,19 @@ +package types + +import ( + "time" + + "github.com/paulmach/orb/geojson" +) + +// SavedSearch represents a saved journey search +type SavedSearch struct { + ID string `json:"id" bson:"_id"` + OwnerID string `json:"owner_id" bson:"owner_id"` + Departure *geojson.Feature `json:"departure" bson:"departure"` + Destination *geojson.Feature `json:"destination" bson:"destination"` + DateTime time.Time `json:"datetime" bson:"datetime"` + Data map[string]interface{} `json:"data" bson:"data"` + CreatedAt time.Time `json:"created_at" bson:"created_at"` + UpdatedAt time.Time `json:"updated_at" bson:"updated_at"` +} \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..8825130 --- /dev/null +++ b/go.mod @@ -0,0 +1,49 @@ +module git.coopgo.io/coopgo-platform/saved-search + +go 1.22 + +require ( + github.com/google/uuid v1.6.0 + github.com/paulmach/orb v0.11.1 + github.com/rs/zerolog v1.33.0 + github.com/spf13/viper v1.19.0 + go.mongodb.org/mongo-driver v1.11.4 + google.golang.org/grpc v1.67.1 + google.golang.org/protobuf v1.35.1 +) + +require ( + github.com/fsnotify/fsnotify v1.7.0 // indirect + github.com/golang/snappy v0.0.4 // indirect + github.com/hashicorp/hcl v1.0.0 // indirect + github.com/klauspost/compress v1.17.2 // indirect + github.com/magiconair/properties v1.8.7 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/montanaflynn/stats v0.7.1 // indirect + github.com/pelletier/go-toml/v2 v2.2.2 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/sagikazarmark/locafero v0.4.0 // indirect + github.com/sagikazarmark/slog-shim v0.1.0 // indirect + github.com/sourcegraph/conc v0.3.0 // indirect + github.com/spf13/afero v1.11.0 // indirect + github.com/spf13/cast v1.6.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect + github.com/subosito/gotenv v1.6.0 // indirect + github.com/xdg-go/pbkdf2 v1.0.0 // indirect + github.com/xdg-go/scram v1.1.2 // indirect + github.com/xdg-go/stringprep v1.0.4 // indirect + github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect + go.uber.org/atomic v1.9.0 // indirect + go.uber.org/multierr v1.9.0 // indirect + golang.org/x/crypto v0.29.0 // indirect + golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect + golang.org/x/net v0.28.0 // indirect + golang.org/x/sync v0.9.0 // indirect + golang.org/x/sys v0.27.0 // indirect + golang.org/x/text v0.20.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect + gopkg.in/ini.v1 v1.67.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..3f67bd9 --- /dev/null +++ b/go.sum @@ -0,0 +1,187 @@ +github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= +github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= +github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= +github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= +github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= +github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= +github.com/klauspost/compress v1.17.2 h1:RlWWUY/Dr4fL8qk9YG7DTZ7PDgME2V4csBXA8L/ixi4= +github.com/klauspost/compress v1.17.2/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= +github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= +github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= +github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE= +github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= +github.com/paulmach/orb v0.11.1 h1:3koVegMC4X/WeiXYz9iswopaTwMem53NzTJuTF20JzU= +github.com/paulmach/orb v0.11.1/go.mod h1:5mULz1xQfs3bmQm63QEJA6lNGujuRafwA5S/EnuLaLU= +github.com/paulmach/protoscan v0.2.1/go.mod h1:SpcSwydNLrxUGSDvXvO0P7g7AuhJ7lcKfDlhJCDw2gY= +github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= +github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= +github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= +github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= +github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= +github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= +github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= +github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= +github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= +github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= +github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY= +github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= +github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI= +github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= +github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= +github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= +github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= +github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= +github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= +github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g= +github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY= +github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4= +github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8= +github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8= +github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM= +github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= +github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM= +github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +go.mongodb.org/mongo-driver v1.11.4 h1:4ayjakA013OdpGyL2K3ZqylTac/rMjrJOMZ1EHizXas= +go.mongodb.org/mongo-driver v1.11.4/go.mod h1:PTSz5yu21bkT/wXpkS7WR5f0ddqw5quethTUn9WM+2g= +go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= +go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= +go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ= +golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg= +golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= +golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= +golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= +golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= +golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= +golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= +golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= +google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= +google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= +google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= +gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/main.go b/main.go new file mode 100644 index 0000000..f5392cd --- /dev/null +++ b/main.go @@ -0,0 +1,48 @@ +package main + +import ( + "os" + + "git.coopgo.io/coopgo-platform/saved-search/core/service" + grpcserver "git.coopgo.io/coopgo-platform/saved-search/servers/grpc/server" + "git.coopgo.io/coopgo-platform/saved-search/data/storage" + "github.com/rs/zerolog" + "github.com/rs/zerolog/log" +) + +func main() { + // zerolog.TimeFieldFormat = zerolog.TimeFormatUnix + cfg, err := ReadConfig() + if err != nil { + panic(err) + } + + var ( + service_name = cfg.GetString("name") + grpc_enable = cfg.GetBool("services.grpc.enable") + dev_env = cfg.GetBool("dev_env") + ) + if dev_env { + log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}) + } + log.Info().Msg("Running " + service_name) + + storageImpl, err := storage.NewStorage(cfg) + if err != nil { + log.Fatal().Err(err).Msg("could not initiate storage") + return + } + + savedSearchService := service.NewSavedSearchService(storageImpl) + + failed := make(chan error) + + if grpc_enable { + log.Info().Msg("Running grpc server") + go grpcserver.Run(failed, cfg, savedSearchService) + } + + err = <-failed + + log.Fatal().Err(err).Msg("Terminating") +} \ No newline at end of file diff --git a/servers/grpc/proto/gen/saved-search.pb.go b/servers/grpc/proto/gen/saved-search.pb.go new file mode 100644 index 0000000..80095d8 --- /dev/null +++ b/servers/grpc/proto/gen/saved-search.pb.go @@ -0,0 +1,985 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.7 +// protoc v6.31.1 +// source: saved-search.proto + +package gen + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + structpb "google.golang.org/protobuf/types/known/structpb" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// GeoJSON Feature representation for saved searches +type SavedSearchGeoJsonFeature struct { + state protoimpl.MessageState `protogen:"open.v1"` + Serialized string `protobuf:"bytes,1,opt,name=serialized,proto3" json:"serialized,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SavedSearchGeoJsonFeature) Reset() { + *x = SavedSearchGeoJsonFeature{} + mi := &file_saved_search_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SavedSearchGeoJsonFeature) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SavedSearchGeoJsonFeature) ProtoMessage() {} + +func (x *SavedSearchGeoJsonFeature) ProtoReflect() protoreflect.Message { + mi := &file_saved_search_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SavedSearchGeoJsonFeature.ProtoReflect.Descriptor instead. +func (*SavedSearchGeoJsonFeature) Descriptor() ([]byte, []int) { + return file_saved_search_proto_rawDescGZIP(), []int{0} +} + +func (x *SavedSearchGeoJsonFeature) GetSerialized() string { + if x != nil { + return x.Serialized + } + return "" +} + +// Saved search message +type SavedSearch struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + OwnerId string `protobuf:"bytes,2,opt,name=owner_id,json=ownerId,proto3" json:"owner_id,omitempty"` + Departure *SavedSearchGeoJsonFeature `protobuf:"bytes,3,opt,name=departure,proto3" json:"departure,omitempty"` + Destination *SavedSearchGeoJsonFeature `protobuf:"bytes,4,opt,name=destination,proto3" json:"destination,omitempty"` + Datetime *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=datetime,proto3" json:"datetime,omitempty"` + Data *structpb.Struct `protobuf:"bytes,6,opt,name=data,proto3" json:"data,omitempty"` + CreatedAt *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` + UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,8,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SavedSearch) Reset() { + *x = SavedSearch{} + mi := &file_saved_search_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SavedSearch) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SavedSearch) ProtoMessage() {} + +func (x *SavedSearch) ProtoReflect() protoreflect.Message { + mi := &file_saved_search_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SavedSearch.ProtoReflect.Descriptor instead. +func (*SavedSearch) Descriptor() ([]byte, []int) { + return file_saved_search_proto_rawDescGZIP(), []int{1} +} + +func (x *SavedSearch) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *SavedSearch) GetOwnerId() string { + if x != nil { + return x.OwnerId + } + return "" +} + +func (x *SavedSearch) GetDeparture() *SavedSearchGeoJsonFeature { + if x != nil { + return x.Departure + } + return nil +} + +func (x *SavedSearch) GetDestination() *SavedSearchGeoJsonFeature { + if x != nil { + return x.Destination + } + return nil +} + +func (x *SavedSearch) GetDatetime() *timestamppb.Timestamp { + if x != nil { + return x.Datetime + } + return nil +} + +func (x *SavedSearch) GetData() *structpb.Struct { + if x != nil { + return x.Data + } + return nil +} + +func (x *SavedSearch) GetCreatedAt() *timestamppb.Timestamp { + if x != nil { + return x.CreatedAt + } + return nil +} + +func (x *SavedSearch) GetUpdatedAt() *timestamppb.Timestamp { + if x != nil { + return x.UpdatedAt + } + return nil +} + +// Create saved search messages +type CreateSavedSearchRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + OwnerId string `protobuf:"bytes,1,opt,name=owner_id,json=ownerId,proto3" json:"owner_id,omitempty"` + Departure *SavedSearchGeoJsonFeature `protobuf:"bytes,2,opt,name=departure,proto3" json:"departure,omitempty"` + Destination *SavedSearchGeoJsonFeature `protobuf:"bytes,3,opt,name=destination,proto3" json:"destination,omitempty"` + Datetime *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=datetime,proto3" json:"datetime,omitempty"` + Data *structpb.Struct `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateSavedSearchRequest) Reset() { + *x = CreateSavedSearchRequest{} + mi := &file_saved_search_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateSavedSearchRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateSavedSearchRequest) ProtoMessage() {} + +func (x *CreateSavedSearchRequest) ProtoReflect() protoreflect.Message { + mi := &file_saved_search_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateSavedSearchRequest.ProtoReflect.Descriptor instead. +func (*CreateSavedSearchRequest) Descriptor() ([]byte, []int) { + return file_saved_search_proto_rawDescGZIP(), []int{2} +} + +func (x *CreateSavedSearchRequest) GetOwnerId() string { + if x != nil { + return x.OwnerId + } + return "" +} + +func (x *CreateSavedSearchRequest) GetDeparture() *SavedSearchGeoJsonFeature { + if x != nil { + return x.Departure + } + return nil +} + +func (x *CreateSavedSearchRequest) GetDestination() *SavedSearchGeoJsonFeature { + if x != nil { + return x.Destination + } + return nil +} + +func (x *CreateSavedSearchRequest) GetDatetime() *timestamppb.Timestamp { + if x != nil { + return x.Datetime + } + return nil +} + +func (x *CreateSavedSearchRequest) GetData() *structpb.Struct { + if x != nil { + return x.Data + } + return nil +} + +type CreateSavedSearchResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + SavedSearch *SavedSearch `protobuf:"bytes,1,opt,name=saved_search,json=savedSearch,proto3" json:"saved_search,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateSavedSearchResponse) Reset() { + *x = CreateSavedSearchResponse{} + mi := &file_saved_search_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateSavedSearchResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateSavedSearchResponse) ProtoMessage() {} + +func (x *CreateSavedSearchResponse) ProtoReflect() protoreflect.Message { + mi := &file_saved_search_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateSavedSearchResponse.ProtoReflect.Descriptor instead. +func (*CreateSavedSearchResponse) Descriptor() ([]byte, []int) { + return file_saved_search_proto_rawDescGZIP(), []int{3} +} + +func (x *CreateSavedSearchResponse) GetSavedSearch() *SavedSearch { + if x != nil { + return x.SavedSearch + } + return nil +} + +// Get saved search messages +type GetSavedSearchRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetSavedSearchRequest) Reset() { + *x = GetSavedSearchRequest{} + mi := &file_saved_search_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetSavedSearchRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetSavedSearchRequest) ProtoMessage() {} + +func (x *GetSavedSearchRequest) ProtoReflect() protoreflect.Message { + mi := &file_saved_search_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetSavedSearchRequest.ProtoReflect.Descriptor instead. +func (*GetSavedSearchRequest) Descriptor() ([]byte, []int) { + return file_saved_search_proto_rawDescGZIP(), []int{4} +} + +func (x *GetSavedSearchRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +type GetSavedSearchResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + SavedSearch *SavedSearch `protobuf:"bytes,1,opt,name=saved_search,json=savedSearch,proto3" json:"saved_search,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetSavedSearchResponse) Reset() { + *x = GetSavedSearchResponse{} + mi := &file_saved_search_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetSavedSearchResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetSavedSearchResponse) ProtoMessage() {} + +func (x *GetSavedSearchResponse) ProtoReflect() protoreflect.Message { + mi := &file_saved_search_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetSavedSearchResponse.ProtoReflect.Descriptor instead. +func (*GetSavedSearchResponse) Descriptor() ([]byte, []int) { + return file_saved_search_proto_rawDescGZIP(), []int{5} +} + +func (x *GetSavedSearchResponse) GetSavedSearch() *SavedSearch { + if x != nil { + return x.SavedSearch + } + return nil +} + +// Get saved searches by owner messages +type GetSavedSearchesByOwnerRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + OwnerId string `protobuf:"bytes,1,opt,name=owner_id,json=ownerId,proto3" json:"owner_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetSavedSearchesByOwnerRequest) Reset() { + *x = GetSavedSearchesByOwnerRequest{} + mi := &file_saved_search_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetSavedSearchesByOwnerRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetSavedSearchesByOwnerRequest) ProtoMessage() {} + +func (x *GetSavedSearchesByOwnerRequest) ProtoReflect() protoreflect.Message { + mi := &file_saved_search_proto_msgTypes[6] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetSavedSearchesByOwnerRequest.ProtoReflect.Descriptor instead. +func (*GetSavedSearchesByOwnerRequest) Descriptor() ([]byte, []int) { + return file_saved_search_proto_rawDescGZIP(), []int{6} +} + +func (x *GetSavedSearchesByOwnerRequest) GetOwnerId() string { + if x != nil { + return x.OwnerId + } + return "" +} + +type GetSavedSearchesByOwnerResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + SavedSearches []*SavedSearch `protobuf:"bytes,1,rep,name=saved_searches,json=savedSearches,proto3" json:"saved_searches,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetSavedSearchesByOwnerResponse) Reset() { + *x = GetSavedSearchesByOwnerResponse{} + mi := &file_saved_search_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetSavedSearchesByOwnerResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetSavedSearchesByOwnerResponse) ProtoMessage() {} + +func (x *GetSavedSearchesByOwnerResponse) ProtoReflect() protoreflect.Message { + mi := &file_saved_search_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetSavedSearchesByOwnerResponse.ProtoReflect.Descriptor instead. +func (*GetSavedSearchesByOwnerResponse) Descriptor() ([]byte, []int) { + return file_saved_search_proto_rawDescGZIP(), []int{7} +} + +func (x *GetSavedSearchesByOwnerResponse) GetSavedSearches() []*SavedSearch { + if x != nil { + return x.SavedSearches + } + return nil +} + +// Update saved search messages +type UpdateSavedSearchRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + OwnerId string `protobuf:"bytes,2,opt,name=owner_id,json=ownerId,proto3" json:"owner_id,omitempty"` + Departure *SavedSearchGeoJsonFeature `protobuf:"bytes,3,opt,name=departure,proto3" json:"departure,omitempty"` + Destination *SavedSearchGeoJsonFeature `protobuf:"bytes,4,opt,name=destination,proto3" json:"destination,omitempty"` + Datetime *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=datetime,proto3" json:"datetime,omitempty"` + Data *structpb.Struct `protobuf:"bytes,6,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateSavedSearchRequest) Reset() { + *x = UpdateSavedSearchRequest{} + mi := &file_saved_search_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateSavedSearchRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateSavedSearchRequest) ProtoMessage() {} + +func (x *UpdateSavedSearchRequest) ProtoReflect() protoreflect.Message { + mi := &file_saved_search_proto_msgTypes[8] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateSavedSearchRequest.ProtoReflect.Descriptor instead. +func (*UpdateSavedSearchRequest) Descriptor() ([]byte, []int) { + return file_saved_search_proto_rawDescGZIP(), []int{8} +} + +func (x *UpdateSavedSearchRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *UpdateSavedSearchRequest) GetOwnerId() string { + if x != nil { + return x.OwnerId + } + return "" +} + +func (x *UpdateSavedSearchRequest) GetDeparture() *SavedSearchGeoJsonFeature { + if x != nil { + return x.Departure + } + return nil +} + +func (x *UpdateSavedSearchRequest) GetDestination() *SavedSearchGeoJsonFeature { + if x != nil { + return x.Destination + } + return nil +} + +func (x *UpdateSavedSearchRequest) GetDatetime() *timestamppb.Timestamp { + if x != nil { + return x.Datetime + } + return nil +} + +func (x *UpdateSavedSearchRequest) GetData() *structpb.Struct { + if x != nil { + return x.Data + } + return nil +} + +type UpdateSavedSearchResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + SavedSearch *SavedSearch `protobuf:"bytes,1,opt,name=saved_search,json=savedSearch,proto3" json:"saved_search,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateSavedSearchResponse) Reset() { + *x = UpdateSavedSearchResponse{} + mi := &file_saved_search_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateSavedSearchResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateSavedSearchResponse) ProtoMessage() {} + +func (x *UpdateSavedSearchResponse) ProtoReflect() protoreflect.Message { + mi := &file_saved_search_proto_msgTypes[9] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateSavedSearchResponse.ProtoReflect.Descriptor instead. +func (*UpdateSavedSearchResponse) Descriptor() ([]byte, []int) { + return file_saved_search_proto_rawDescGZIP(), []int{9} +} + +func (x *UpdateSavedSearchResponse) GetSavedSearch() *SavedSearch { + if x != nil { + return x.SavedSearch + } + return nil +} + +// Delete saved search messages +type DeleteSavedSearchRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + OwnerId string `protobuf:"bytes,2,opt,name=owner_id,json=ownerId,proto3" json:"owner_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteSavedSearchRequest) Reset() { + *x = DeleteSavedSearchRequest{} + mi := &file_saved_search_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteSavedSearchRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteSavedSearchRequest) ProtoMessage() {} + +func (x *DeleteSavedSearchRequest) ProtoReflect() protoreflect.Message { + mi := &file_saved_search_proto_msgTypes[10] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteSavedSearchRequest.ProtoReflect.Descriptor instead. +func (*DeleteSavedSearchRequest) Descriptor() ([]byte, []int) { + return file_saved_search_proto_rawDescGZIP(), []int{10} +} + +func (x *DeleteSavedSearchRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *DeleteSavedSearchRequest) GetOwnerId() string { + if x != nil { + return x.OwnerId + } + return "" +} + +type DeleteSavedSearchResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteSavedSearchResponse) Reset() { + *x = DeleteSavedSearchResponse{} + mi := &file_saved_search_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteSavedSearchResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteSavedSearchResponse) ProtoMessage() {} + +func (x *DeleteSavedSearchResponse) ProtoReflect() protoreflect.Message { + mi := &file_saved_search_proto_msgTypes[11] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteSavedSearchResponse.ProtoReflect.Descriptor instead. +func (*DeleteSavedSearchResponse) Descriptor() ([]byte, []int) { + return file_saved_search_proto_rawDescGZIP(), []int{11} +} + +func (x *DeleteSavedSearchResponse) GetSuccess() bool { + if x != nil { + return x.Success + } + return false +} + +// List saved searches messages +type ListSavedSearchesRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + OwnerId string `protobuf:"bytes,1,opt,name=owner_id,json=ownerId,proto3" json:"owner_id,omitempty"` + Limit int32 `protobuf:"varint,2,opt,name=limit,proto3" json:"limit,omitempty"` + Offset int32 `protobuf:"varint,3,opt,name=offset,proto3" json:"offset,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListSavedSearchesRequest) Reset() { + *x = ListSavedSearchesRequest{} + mi := &file_saved_search_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListSavedSearchesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListSavedSearchesRequest) ProtoMessage() {} + +func (x *ListSavedSearchesRequest) ProtoReflect() protoreflect.Message { + mi := &file_saved_search_proto_msgTypes[12] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListSavedSearchesRequest.ProtoReflect.Descriptor instead. +func (*ListSavedSearchesRequest) Descriptor() ([]byte, []int) { + return file_saved_search_proto_rawDescGZIP(), []int{12} +} + +func (x *ListSavedSearchesRequest) GetOwnerId() string { + if x != nil { + return x.OwnerId + } + return "" +} + +func (x *ListSavedSearchesRequest) GetLimit() int32 { + if x != nil { + return x.Limit + } + return 0 +} + +func (x *ListSavedSearchesRequest) GetOffset() int32 { + if x != nil { + return x.Offset + } + return 0 +} + +type ListSavedSearchesResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + SavedSearches []*SavedSearch `protobuf:"bytes,1,rep,name=saved_searches,json=savedSearches,proto3" json:"saved_searches,omitempty"` + Total int64 `protobuf:"varint,2,opt,name=total,proto3" json:"total,omitempty"` + Limit int32 `protobuf:"varint,3,opt,name=limit,proto3" json:"limit,omitempty"` + Offset int32 `protobuf:"varint,4,opt,name=offset,proto3" json:"offset,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListSavedSearchesResponse) Reset() { + *x = ListSavedSearchesResponse{} + mi := &file_saved_search_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListSavedSearchesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListSavedSearchesResponse) ProtoMessage() {} + +func (x *ListSavedSearchesResponse) ProtoReflect() protoreflect.Message { + mi := &file_saved_search_proto_msgTypes[13] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListSavedSearchesResponse.ProtoReflect.Descriptor instead. +func (*ListSavedSearchesResponse) Descriptor() ([]byte, []int) { + return file_saved_search_proto_rawDescGZIP(), []int{13} +} + +func (x *ListSavedSearchesResponse) GetSavedSearches() []*SavedSearch { + if x != nil { + return x.SavedSearches + } + return nil +} + +func (x *ListSavedSearchesResponse) GetTotal() int64 { + if x != nil { + return x.Total + } + return 0 +} + +func (x *ListSavedSearchesResponse) GetLimit() int32 { + if x != nil { + return x.Limit + } + return 0 +} + +func (x *ListSavedSearchesResponse) GetOffset() int32 { + if x != nil { + return x.Offset + } + return 0 +} + +var File_saved_search_proto protoreflect.FileDescriptor + +const file_saved_search_proto_rawDesc = "" + + "\n" + + "\x12saved-search.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1cgoogle/protobuf/struct.proto\";\n" + + "\x19SavedSearchGeoJsonFeature\x12\x1e\n" + + "\n" + + "serialized\x18\x01 \x01(\tR\n" + + "serialized\"\x8b\x03\n" + + "\vSavedSearch\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12\x19\n" + + "\bowner_id\x18\x02 \x01(\tR\aownerId\x128\n" + + "\tdeparture\x18\x03 \x01(\v2\x1a.SavedSearchGeoJsonFeatureR\tdeparture\x12<\n" + + "\vdestination\x18\x04 \x01(\v2\x1a.SavedSearchGeoJsonFeatureR\vdestination\x126\n" + + "\bdatetime\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\bdatetime\x12+\n" + + "\x04data\x18\x06 \x01(\v2\x17.google.protobuf.StructR\x04data\x129\n" + + "\n" + + "created_at\x18\a \x01(\v2\x1a.google.protobuf.TimestampR\tcreatedAt\x129\n" + + "\n" + + "updated_at\x18\b \x01(\v2\x1a.google.protobuf.TimestampR\tupdatedAt\"\x92\x02\n" + + "\x18CreateSavedSearchRequest\x12\x19\n" + + "\bowner_id\x18\x01 \x01(\tR\aownerId\x128\n" + + "\tdeparture\x18\x02 \x01(\v2\x1a.SavedSearchGeoJsonFeatureR\tdeparture\x12<\n" + + "\vdestination\x18\x03 \x01(\v2\x1a.SavedSearchGeoJsonFeatureR\vdestination\x126\n" + + "\bdatetime\x18\x04 \x01(\v2\x1a.google.protobuf.TimestampR\bdatetime\x12+\n" + + "\x04data\x18\x05 \x01(\v2\x17.google.protobuf.StructR\x04data\"L\n" + + "\x19CreateSavedSearchResponse\x12/\n" + + "\fsaved_search\x18\x01 \x01(\v2\f.SavedSearchR\vsavedSearch\"'\n" + + "\x15GetSavedSearchRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\"I\n" + + "\x16GetSavedSearchResponse\x12/\n" + + "\fsaved_search\x18\x01 \x01(\v2\f.SavedSearchR\vsavedSearch\";\n" + + "\x1eGetSavedSearchesByOwnerRequest\x12\x19\n" + + "\bowner_id\x18\x01 \x01(\tR\aownerId\"V\n" + + "\x1fGetSavedSearchesByOwnerResponse\x123\n" + + "\x0esaved_searches\x18\x01 \x03(\v2\f.SavedSearchR\rsavedSearches\"\xa2\x02\n" + + "\x18UpdateSavedSearchRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12\x19\n" + + "\bowner_id\x18\x02 \x01(\tR\aownerId\x128\n" + + "\tdeparture\x18\x03 \x01(\v2\x1a.SavedSearchGeoJsonFeatureR\tdeparture\x12<\n" + + "\vdestination\x18\x04 \x01(\v2\x1a.SavedSearchGeoJsonFeatureR\vdestination\x126\n" + + "\bdatetime\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\bdatetime\x12+\n" + + "\x04data\x18\x06 \x01(\v2\x17.google.protobuf.StructR\x04data\"L\n" + + "\x19UpdateSavedSearchResponse\x12/\n" + + "\fsaved_search\x18\x01 \x01(\v2\f.SavedSearchR\vsavedSearch\"E\n" + + "\x18DeleteSavedSearchRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12\x19\n" + + "\bowner_id\x18\x02 \x01(\tR\aownerId\"5\n" + + "\x19DeleteSavedSearchResponse\x12\x18\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess\"c\n" + + "\x18ListSavedSearchesRequest\x12\x19\n" + + "\bowner_id\x18\x01 \x01(\tR\aownerId\x12\x14\n" + + "\x05limit\x18\x02 \x01(\x05R\x05limit\x12\x16\n" + + "\x06offset\x18\x03 \x01(\x05R\x06offset\"\x94\x01\n" + + "\x19ListSavedSearchesResponse\x123\n" + + "\x0esaved_searches\x18\x01 \x03(\v2\f.SavedSearchR\rsavedSearches\x12\x14\n" + + "\x05total\x18\x02 \x01(\x03R\x05total\x12\x14\n" + + "\x05limit\x18\x03 \x01(\x05R\x05limit\x12\x16\n" + + "\x06offset\x18\x04 \x01(\x05R\x06offset2\xf1\x03\n" + + "\x12SavedSearchService\x12L\n" + + "\x11CreateSavedSearch\x12\x19.CreateSavedSearchRequest\x1a\x1a.CreateSavedSearchResponse\"\x00\x12C\n" + + "\x0eGetSavedSearch\x12\x16.GetSavedSearchRequest\x1a\x17.GetSavedSearchResponse\"\x00\x12^\n" + + "\x17GetSavedSearchesByOwner\x12\x1f.GetSavedSearchesByOwnerRequest\x1a .GetSavedSearchesByOwnerResponse\"\x00\x12L\n" + + "\x11UpdateSavedSearch\x12\x19.UpdateSavedSearchRequest\x1a\x1a.UpdateSavedSearchResponse\"\x00\x12L\n" + + "\x11DeleteSavedSearch\x12\x19.DeleteSavedSearchRequest\x1a\x1a.DeleteSavedSearchResponse\"\x00\x12L\n" + + "\x11ListSavedSearches\x12\x19.ListSavedSearchesRequest\x1a\x1a.ListSavedSearchesResponse\"\x00BCZAgit.coopgo.io/coopgo-platform/saved-search/servers/grpc/proto/genb\x06proto3" + +var ( + file_saved_search_proto_rawDescOnce sync.Once + file_saved_search_proto_rawDescData []byte +) + +func file_saved_search_proto_rawDescGZIP() []byte { + file_saved_search_proto_rawDescOnce.Do(func() { + file_saved_search_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_saved_search_proto_rawDesc), len(file_saved_search_proto_rawDesc))) + }) + return file_saved_search_proto_rawDescData +} + +var file_saved_search_proto_msgTypes = make([]protoimpl.MessageInfo, 14) +var file_saved_search_proto_goTypes = []any{ + (*SavedSearchGeoJsonFeature)(nil), // 0: SavedSearchGeoJsonFeature + (*SavedSearch)(nil), // 1: SavedSearch + (*CreateSavedSearchRequest)(nil), // 2: CreateSavedSearchRequest + (*CreateSavedSearchResponse)(nil), // 3: CreateSavedSearchResponse + (*GetSavedSearchRequest)(nil), // 4: GetSavedSearchRequest + (*GetSavedSearchResponse)(nil), // 5: GetSavedSearchResponse + (*GetSavedSearchesByOwnerRequest)(nil), // 6: GetSavedSearchesByOwnerRequest + (*GetSavedSearchesByOwnerResponse)(nil), // 7: GetSavedSearchesByOwnerResponse + (*UpdateSavedSearchRequest)(nil), // 8: UpdateSavedSearchRequest + (*UpdateSavedSearchResponse)(nil), // 9: UpdateSavedSearchResponse + (*DeleteSavedSearchRequest)(nil), // 10: DeleteSavedSearchRequest + (*DeleteSavedSearchResponse)(nil), // 11: DeleteSavedSearchResponse + (*ListSavedSearchesRequest)(nil), // 12: ListSavedSearchesRequest + (*ListSavedSearchesResponse)(nil), // 13: ListSavedSearchesResponse + (*timestamppb.Timestamp)(nil), // 14: google.protobuf.Timestamp + (*structpb.Struct)(nil), // 15: google.protobuf.Struct +} +var file_saved_search_proto_depIdxs = []int32{ + 0, // 0: SavedSearch.departure:type_name -> SavedSearchGeoJsonFeature + 0, // 1: SavedSearch.destination:type_name -> SavedSearchGeoJsonFeature + 14, // 2: SavedSearch.datetime:type_name -> google.protobuf.Timestamp + 15, // 3: SavedSearch.data:type_name -> google.protobuf.Struct + 14, // 4: SavedSearch.created_at:type_name -> google.protobuf.Timestamp + 14, // 5: SavedSearch.updated_at:type_name -> google.protobuf.Timestamp + 0, // 6: CreateSavedSearchRequest.departure:type_name -> SavedSearchGeoJsonFeature + 0, // 7: CreateSavedSearchRequest.destination:type_name -> SavedSearchGeoJsonFeature + 14, // 8: CreateSavedSearchRequest.datetime:type_name -> google.protobuf.Timestamp + 15, // 9: CreateSavedSearchRequest.data:type_name -> google.protobuf.Struct + 1, // 10: CreateSavedSearchResponse.saved_search:type_name -> SavedSearch + 1, // 11: GetSavedSearchResponse.saved_search:type_name -> SavedSearch + 1, // 12: GetSavedSearchesByOwnerResponse.saved_searches:type_name -> SavedSearch + 0, // 13: UpdateSavedSearchRequest.departure:type_name -> SavedSearchGeoJsonFeature + 0, // 14: UpdateSavedSearchRequest.destination:type_name -> SavedSearchGeoJsonFeature + 14, // 15: UpdateSavedSearchRequest.datetime:type_name -> google.protobuf.Timestamp + 15, // 16: UpdateSavedSearchRequest.data:type_name -> google.protobuf.Struct + 1, // 17: UpdateSavedSearchResponse.saved_search:type_name -> SavedSearch + 1, // 18: ListSavedSearchesResponse.saved_searches:type_name -> SavedSearch + 2, // 19: SavedSearchService.CreateSavedSearch:input_type -> CreateSavedSearchRequest + 4, // 20: SavedSearchService.GetSavedSearch:input_type -> GetSavedSearchRequest + 6, // 21: SavedSearchService.GetSavedSearchesByOwner:input_type -> GetSavedSearchesByOwnerRequest + 8, // 22: SavedSearchService.UpdateSavedSearch:input_type -> UpdateSavedSearchRequest + 10, // 23: SavedSearchService.DeleteSavedSearch:input_type -> DeleteSavedSearchRequest + 12, // 24: SavedSearchService.ListSavedSearches:input_type -> ListSavedSearchesRequest + 3, // 25: SavedSearchService.CreateSavedSearch:output_type -> CreateSavedSearchResponse + 5, // 26: SavedSearchService.GetSavedSearch:output_type -> GetSavedSearchResponse + 7, // 27: SavedSearchService.GetSavedSearchesByOwner:output_type -> GetSavedSearchesByOwnerResponse + 9, // 28: SavedSearchService.UpdateSavedSearch:output_type -> UpdateSavedSearchResponse + 11, // 29: SavedSearchService.DeleteSavedSearch:output_type -> DeleteSavedSearchResponse + 13, // 30: SavedSearchService.ListSavedSearches:output_type -> ListSavedSearchesResponse + 25, // [25:31] is the sub-list for method output_type + 19, // [19:25] is the sub-list for method input_type + 19, // [19:19] is the sub-list for extension type_name + 19, // [19:19] is the sub-list for extension extendee + 0, // [0:19] is the sub-list for field type_name +} + +func init() { file_saved_search_proto_init() } +func file_saved_search_proto_init() { + if File_saved_search_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_saved_search_proto_rawDesc), len(file_saved_search_proto_rawDesc)), + NumEnums: 0, + NumMessages: 14, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_saved_search_proto_goTypes, + DependencyIndexes: file_saved_search_proto_depIdxs, + MessageInfos: file_saved_search_proto_msgTypes, + }.Build() + File_saved_search_proto = out.File + file_saved_search_proto_goTypes = nil + file_saved_search_proto_depIdxs = nil +} diff --git a/servers/grpc/proto/gen/saved-search_grpc.pb.go b/servers/grpc/proto/gen/saved-search_grpc.pb.go new file mode 100644 index 0000000..bbca296 --- /dev/null +++ b/servers/grpc/proto/gen/saved-search_grpc.pb.go @@ -0,0 +1,323 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc v6.31.1 +// source: saved-search.proto + +package gen + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + SavedSearchService_CreateSavedSearch_FullMethodName = "/SavedSearchService/CreateSavedSearch" + SavedSearchService_GetSavedSearch_FullMethodName = "/SavedSearchService/GetSavedSearch" + SavedSearchService_GetSavedSearchesByOwner_FullMethodName = "/SavedSearchService/GetSavedSearchesByOwner" + SavedSearchService_UpdateSavedSearch_FullMethodName = "/SavedSearchService/UpdateSavedSearch" + SavedSearchService_DeleteSavedSearch_FullMethodName = "/SavedSearchService/DeleteSavedSearch" + SavedSearchService_ListSavedSearches_FullMethodName = "/SavedSearchService/ListSavedSearches" +) + +// SavedSearchServiceClient is the client API for SavedSearchService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type SavedSearchServiceClient interface { + // Create a new saved search + CreateSavedSearch(ctx context.Context, in *CreateSavedSearchRequest, opts ...grpc.CallOption) (*CreateSavedSearchResponse, error) + // Get a saved search by ID + GetSavedSearch(ctx context.Context, in *GetSavedSearchRequest, opts ...grpc.CallOption) (*GetSavedSearchResponse, error) + // Get all saved searches for a specific owner + GetSavedSearchesByOwner(ctx context.Context, in *GetSavedSearchesByOwnerRequest, opts ...grpc.CallOption) (*GetSavedSearchesByOwnerResponse, error) + // Update an existing saved search + UpdateSavedSearch(ctx context.Context, in *UpdateSavedSearchRequest, opts ...grpc.CallOption) (*UpdateSavedSearchResponse, error) + // Delete a saved search + DeleteSavedSearch(ctx context.Context, in *DeleteSavedSearchRequest, opts ...grpc.CallOption) (*DeleteSavedSearchResponse, error) + // List saved searches with pagination + ListSavedSearches(ctx context.Context, in *ListSavedSearchesRequest, opts ...grpc.CallOption) (*ListSavedSearchesResponse, error) +} + +type savedSearchServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewSavedSearchServiceClient(cc grpc.ClientConnInterface) SavedSearchServiceClient { + return &savedSearchServiceClient{cc} +} + +func (c *savedSearchServiceClient) CreateSavedSearch(ctx context.Context, in *CreateSavedSearchRequest, opts ...grpc.CallOption) (*CreateSavedSearchResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CreateSavedSearchResponse) + err := c.cc.Invoke(ctx, SavedSearchService_CreateSavedSearch_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *savedSearchServiceClient) GetSavedSearch(ctx context.Context, in *GetSavedSearchRequest, opts ...grpc.CallOption) (*GetSavedSearchResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetSavedSearchResponse) + err := c.cc.Invoke(ctx, SavedSearchService_GetSavedSearch_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *savedSearchServiceClient) GetSavedSearchesByOwner(ctx context.Context, in *GetSavedSearchesByOwnerRequest, opts ...grpc.CallOption) (*GetSavedSearchesByOwnerResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetSavedSearchesByOwnerResponse) + err := c.cc.Invoke(ctx, SavedSearchService_GetSavedSearchesByOwner_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *savedSearchServiceClient) UpdateSavedSearch(ctx context.Context, in *UpdateSavedSearchRequest, opts ...grpc.CallOption) (*UpdateSavedSearchResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UpdateSavedSearchResponse) + err := c.cc.Invoke(ctx, SavedSearchService_UpdateSavedSearch_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *savedSearchServiceClient) DeleteSavedSearch(ctx context.Context, in *DeleteSavedSearchRequest, opts ...grpc.CallOption) (*DeleteSavedSearchResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(DeleteSavedSearchResponse) + err := c.cc.Invoke(ctx, SavedSearchService_DeleteSavedSearch_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *savedSearchServiceClient) ListSavedSearches(ctx context.Context, in *ListSavedSearchesRequest, opts ...grpc.CallOption) (*ListSavedSearchesResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ListSavedSearchesResponse) + err := c.cc.Invoke(ctx, SavedSearchService_ListSavedSearches_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// SavedSearchServiceServer is the server API for SavedSearchService service. +// All implementations must embed UnimplementedSavedSearchServiceServer +// for forward compatibility. +type SavedSearchServiceServer interface { + // Create a new saved search + CreateSavedSearch(context.Context, *CreateSavedSearchRequest) (*CreateSavedSearchResponse, error) + // Get a saved search by ID + GetSavedSearch(context.Context, *GetSavedSearchRequest) (*GetSavedSearchResponse, error) + // Get all saved searches for a specific owner + GetSavedSearchesByOwner(context.Context, *GetSavedSearchesByOwnerRequest) (*GetSavedSearchesByOwnerResponse, error) + // Update an existing saved search + UpdateSavedSearch(context.Context, *UpdateSavedSearchRequest) (*UpdateSavedSearchResponse, error) + // Delete a saved search + DeleteSavedSearch(context.Context, *DeleteSavedSearchRequest) (*DeleteSavedSearchResponse, error) + // List saved searches with pagination + ListSavedSearches(context.Context, *ListSavedSearchesRequest) (*ListSavedSearchesResponse, error) + mustEmbedUnimplementedSavedSearchServiceServer() +} + +// UnimplementedSavedSearchServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedSavedSearchServiceServer struct{} + +func (UnimplementedSavedSearchServiceServer) CreateSavedSearch(context.Context, *CreateSavedSearchRequest) (*CreateSavedSearchResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateSavedSearch not implemented") +} +func (UnimplementedSavedSearchServiceServer) GetSavedSearch(context.Context, *GetSavedSearchRequest) (*GetSavedSearchResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetSavedSearch not implemented") +} +func (UnimplementedSavedSearchServiceServer) GetSavedSearchesByOwner(context.Context, *GetSavedSearchesByOwnerRequest) (*GetSavedSearchesByOwnerResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetSavedSearchesByOwner not implemented") +} +func (UnimplementedSavedSearchServiceServer) UpdateSavedSearch(context.Context, *UpdateSavedSearchRequest) (*UpdateSavedSearchResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateSavedSearch not implemented") +} +func (UnimplementedSavedSearchServiceServer) DeleteSavedSearch(context.Context, *DeleteSavedSearchRequest) (*DeleteSavedSearchResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteSavedSearch not implemented") +} +func (UnimplementedSavedSearchServiceServer) ListSavedSearches(context.Context, *ListSavedSearchesRequest) (*ListSavedSearchesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListSavedSearches not implemented") +} +func (UnimplementedSavedSearchServiceServer) mustEmbedUnimplementedSavedSearchServiceServer() {} +func (UnimplementedSavedSearchServiceServer) testEmbeddedByValue() {} + +// UnsafeSavedSearchServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to SavedSearchServiceServer will +// result in compilation errors. +type UnsafeSavedSearchServiceServer interface { + mustEmbedUnimplementedSavedSearchServiceServer() +} + +func RegisterSavedSearchServiceServer(s grpc.ServiceRegistrar, srv SavedSearchServiceServer) { + // If the following call pancis, it indicates UnimplementedSavedSearchServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&SavedSearchService_ServiceDesc, srv) +} + +func _SavedSearchService_CreateSavedSearch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateSavedSearchRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SavedSearchServiceServer).CreateSavedSearch(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SavedSearchService_CreateSavedSearch_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SavedSearchServiceServer).CreateSavedSearch(ctx, req.(*CreateSavedSearchRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _SavedSearchService_GetSavedSearch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetSavedSearchRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SavedSearchServiceServer).GetSavedSearch(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SavedSearchService_GetSavedSearch_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SavedSearchServiceServer).GetSavedSearch(ctx, req.(*GetSavedSearchRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _SavedSearchService_GetSavedSearchesByOwner_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetSavedSearchesByOwnerRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SavedSearchServiceServer).GetSavedSearchesByOwner(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SavedSearchService_GetSavedSearchesByOwner_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SavedSearchServiceServer).GetSavedSearchesByOwner(ctx, req.(*GetSavedSearchesByOwnerRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _SavedSearchService_UpdateSavedSearch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateSavedSearchRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SavedSearchServiceServer).UpdateSavedSearch(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SavedSearchService_UpdateSavedSearch_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SavedSearchServiceServer).UpdateSavedSearch(ctx, req.(*UpdateSavedSearchRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _SavedSearchService_DeleteSavedSearch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteSavedSearchRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SavedSearchServiceServer).DeleteSavedSearch(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SavedSearchService_DeleteSavedSearch_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SavedSearchServiceServer).DeleteSavedSearch(ctx, req.(*DeleteSavedSearchRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _SavedSearchService_ListSavedSearches_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListSavedSearchesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SavedSearchServiceServer).ListSavedSearches(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SavedSearchService_ListSavedSearches_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SavedSearchServiceServer).ListSavedSearches(ctx, req.(*ListSavedSearchesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// SavedSearchService_ServiceDesc is the grpc.ServiceDesc for SavedSearchService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var SavedSearchService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "SavedSearchService", + HandlerType: (*SavedSearchServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "CreateSavedSearch", + Handler: _SavedSearchService_CreateSavedSearch_Handler, + }, + { + MethodName: "GetSavedSearch", + Handler: _SavedSearchService_GetSavedSearch_Handler, + }, + { + MethodName: "GetSavedSearchesByOwner", + Handler: _SavedSearchService_GetSavedSearchesByOwner_Handler, + }, + { + MethodName: "UpdateSavedSearch", + Handler: _SavedSearchService_UpdateSavedSearch_Handler, + }, + { + MethodName: "DeleteSavedSearch", + Handler: _SavedSearchService_DeleteSavedSearch_Handler, + }, + { + MethodName: "ListSavedSearches", + Handler: _SavedSearchService_ListSavedSearches_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "saved-search.proto", +} diff --git a/servers/grpc/proto/saved-search.proto b/servers/grpc/proto/saved-search.proto new file mode 100644 index 0000000..4ea5cd0 --- /dev/null +++ b/servers/grpc/proto/saved-search.proto @@ -0,0 +1,112 @@ +syntax = "proto3"; + +option go_package = "git.coopgo.io/coopgo-platform/saved-search/servers/grpc/proto/gen"; + +import "google/protobuf/timestamp.proto"; +import "google/protobuf/struct.proto"; + +service SavedSearchService { + // Create a new saved search + rpc CreateSavedSearch(CreateSavedSearchRequest) returns (CreateSavedSearchResponse) {} + + // Get a saved search by ID + rpc GetSavedSearch(GetSavedSearchRequest) returns (GetSavedSearchResponse) {} + + // Get all saved searches for a specific owner + rpc GetSavedSearchesByOwner(GetSavedSearchesByOwnerRequest) returns (GetSavedSearchesByOwnerResponse) {} + + // Update an existing saved search + rpc UpdateSavedSearch(UpdateSavedSearchRequest) returns (UpdateSavedSearchResponse) {} + + // Delete a saved search + rpc DeleteSavedSearch(DeleteSavedSearchRequest) returns (DeleteSavedSearchResponse) {} + + // List saved searches with pagination + rpc ListSavedSearches(ListSavedSearchesRequest) returns (ListSavedSearchesResponse) {} +} + +// GeoJSON Feature representation for saved searches +message SavedSearchGeoJsonFeature { + string serialized = 1; +} + +// Saved search message +message SavedSearch { + string id = 1; + string owner_id = 2; + SavedSearchGeoJsonFeature departure = 3; + SavedSearchGeoJsonFeature destination = 4; + google.protobuf.Timestamp datetime = 5; + google.protobuf.Struct data = 6; + google.protobuf.Timestamp created_at = 7; + google.protobuf.Timestamp updated_at = 8; +} + +// Create saved search messages +message CreateSavedSearchRequest { + string owner_id = 1; + SavedSearchGeoJsonFeature departure = 2; + SavedSearchGeoJsonFeature destination = 3; + google.protobuf.Timestamp datetime = 4; + google.protobuf.Struct data = 5; +} + +message CreateSavedSearchResponse { + SavedSearch saved_search = 1; +} + +// Get saved search messages +message GetSavedSearchRequest { + string id = 1; +} + +message GetSavedSearchResponse { + SavedSearch saved_search = 1; +} + +// Get saved searches by owner messages +message GetSavedSearchesByOwnerRequest { + string owner_id = 1; +} + +message GetSavedSearchesByOwnerResponse { + repeated SavedSearch saved_searches = 1; +} + +// Update saved search messages +message UpdateSavedSearchRequest { + string id = 1; + string owner_id = 2; + SavedSearchGeoJsonFeature departure = 3; + SavedSearchGeoJsonFeature destination = 4; + google.protobuf.Timestamp datetime = 5; + google.protobuf.Struct data = 6; +} + +message UpdateSavedSearchResponse { + SavedSearch saved_search = 1; +} + +// Delete saved search messages +message DeleteSavedSearchRequest { + string id = 1; + string owner_id = 2; +} + +message DeleteSavedSearchResponse { + bool success = 1; +} + +// List saved searches messages +message ListSavedSearchesRequest { + string owner_id = 1; + int32 limit = 2; + int32 offset = 3; +} + +message ListSavedSearchesResponse { + repeated SavedSearch saved_searches = 1; + int64 total = 2; + int32 limit = 3; + int32 offset = 4; +} \ No newline at end of file diff --git a/servers/grpc/server/server.go b/servers/grpc/server/server.go new file mode 100644 index 0000000..74e67fc --- /dev/null +++ b/servers/grpc/server/server.go @@ -0,0 +1,232 @@ +package server + +import ( + "context" + "fmt" + "net" + + "git.coopgo.io/coopgo-platform/saved-search/core/service" + "git.coopgo.io/coopgo-platform/saved-search/servers/grpc/proto/gen" + "git.coopgo.io/coopgo-platform/saved-search/servers/grpc/transformers" + "github.com/rs/zerolog/log" + "github.com/spf13/viper" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/reflection" + "google.golang.org/grpc/status" +) + +// SavedSearchServerImpl implements the SavedSearchService gRPC service +type SavedSearchServerImpl struct { + gen.UnimplementedSavedSearchServiceServer + service *service.SavedSearchService +} + +// NewSavedSearchServerImpl creates a new SavedSearchServerImpl +func NewSavedSearchServerImpl(service *service.SavedSearchService) *SavedSearchServerImpl { + return &SavedSearchServerImpl{ + service: service, + } +} + +// CreateSavedSearch creates a new saved search +func (s *SavedSearchServerImpl) CreateSavedSearch(ctx context.Context, req *gen.CreateSavedSearchRequest) (*gen.CreateSavedSearchResponse, error) { + departure, err := transformers.GeoJsonFeatureFromProto(req.Departure) + if err != nil { + log.Error().Err(err).Msg("failed to convert departure") + return nil, status.Errorf(codes.InvalidArgument, "invalid departure: %v", err) + } + + destination, err := transformers.GeoJsonFeatureFromProto(req.Destination) + if err != nil { + log.Error().Err(err).Msg("failed to convert destination") + return nil, status.Errorf(codes.InvalidArgument, "invalid destination: %v", err) + } + + var data map[string]interface{} + if req.Data != nil { + data = req.Data.AsMap() + } + + params := service.CreateSavedSearchParams{ + OwnerID: req.OwnerId, + Departure: departure, + Destination: destination, + DateTime: req.Datetime.AsTime(), + Data: data, + } + + search, err := s.service.CreateSavedSearch(ctx, params) + if err != nil { + log.Error().Err(err).Msg("failed to create saved search") + return nil, status.Errorf(codes.Internal, "failed to create saved search: %v", err) + } + + protoSearch, err := transformers.SavedSearchTypeToProto(search) + if err != nil { + log.Error().Err(err).Msg("failed to convert saved search to proto") + return nil, status.Errorf(codes.Internal, "failed to convert saved search: %v", err) + } + + return &gen.CreateSavedSearchResponse{ + SavedSearch: protoSearch, + }, nil +} + +// GetSavedSearch retrieves a saved search by ID +func (s *SavedSearchServerImpl) GetSavedSearch(ctx context.Context, req *gen.GetSavedSearchRequest) (*gen.GetSavedSearchResponse, error) { + search, err := s.service.GetSavedSearch(ctx, req.Id) + if err != nil { + log.Error().Err(err).Str("id", req.Id).Msg("failed to get saved search") + return nil, status.Errorf(codes.NotFound, "saved search not found: %v", err) + } + + protoSearch, err := transformers.SavedSearchTypeToProto(search) + if err != nil { + log.Error().Err(err).Msg("failed to convert saved search to proto") + return nil, status.Errorf(codes.Internal, "failed to convert saved search: %v", err) + } + + return &gen.GetSavedSearchResponse{ + SavedSearch: protoSearch, + }, nil +} + +// GetSavedSearchesByOwner retrieves all saved searches for a specific owner +func (s *SavedSearchServerImpl) GetSavedSearchesByOwner(ctx context.Context, req *gen.GetSavedSearchesByOwnerRequest) (*gen.GetSavedSearchesByOwnerResponse, error) { + searches, err := s.service.GetSavedSearchesByOwner(ctx, req.OwnerId) + if err != nil { + log.Error().Err(err).Str("owner_id", req.OwnerId).Msg("failed to get saved searches by owner") + return nil, status.Errorf(codes.Internal, "failed to get saved searches: %v", err) + } + + var protoSearches []*gen.SavedSearch + for _, search := range searches { + protoSearch, err := transformers.SavedSearchTypeToProto(search) + if err != nil { + log.Error().Err(err).Str("id", search.ID).Msg("failed to convert saved search to proto") + continue + } + protoSearches = append(protoSearches, protoSearch) + } + + return &gen.GetSavedSearchesByOwnerResponse{ + SavedSearches: protoSearches, + }, nil +} + +// UpdateSavedSearch updates an existing saved search +func (s *SavedSearchServerImpl) UpdateSavedSearch(ctx context.Context, req *gen.UpdateSavedSearchRequest) (*gen.UpdateSavedSearchResponse, error) { + departure, err := transformers.GeoJsonFeatureFromProto(req.Departure) + if err != nil { + log.Error().Err(err).Msg("failed to convert departure") + return nil, status.Errorf(codes.InvalidArgument, "invalid departure: %v", err) + } + + destination, err := transformers.GeoJsonFeatureFromProto(req.Destination) + if err != nil { + log.Error().Err(err).Msg("failed to convert destination") + return nil, status.Errorf(codes.InvalidArgument, "invalid destination: %v", err) + } + + var data map[string]interface{} + if req.Data != nil { + data = req.Data.AsMap() + } + + params := service.UpdateSavedSearchParams{ + ID: req.Id, + OwnerID: req.OwnerId, + Departure: departure, + Destination: destination, + DateTime: req.Datetime.AsTime(), + Data: data, + } + + search, err := s.service.UpdateSavedSearch(ctx, params) + if err != nil { + log.Error().Err(err).Str("id", req.Id).Msg("failed to update saved search") + return nil, status.Errorf(codes.Internal, "failed to update saved search: %v", err) + } + + protoSearch, err := transformers.SavedSearchTypeToProto(search) + if err != nil { + log.Error().Err(err).Msg("failed to convert saved search to proto") + return nil, status.Errorf(codes.Internal, "failed to convert saved search: %v", err) + } + + return &gen.UpdateSavedSearchResponse{ + SavedSearch: protoSearch, + }, nil +} + +// DeleteSavedSearch deletes a saved search +func (s *SavedSearchServerImpl) DeleteSavedSearch(ctx context.Context, req *gen.DeleteSavedSearchRequest) (*gen.DeleteSavedSearchResponse, error) { + err := s.service.DeleteSavedSearch(ctx, req.Id, req.OwnerId) + if err != nil { + log.Error().Err(err).Str("id", req.Id).Msg("failed to delete saved search") + return nil, status.Errorf(codes.Internal, "failed to delete saved search: %v", err) + } + + return &gen.DeleteSavedSearchResponse{ + Success: true, + }, nil +} + +// ListSavedSearches retrieves paginated saved searches +func (s *SavedSearchServerImpl) ListSavedSearches(ctx context.Context, req *gen.ListSavedSearchesRequest) (*gen.ListSavedSearchesResponse, error) { + params := service.ListSavedSearchesParams{ + OwnerID: req.OwnerId, + Limit: int(req.Limit), + Offset: int(req.Offset), + } + + result, err := s.service.ListSavedSearches(ctx, params) + if err != nil { + log.Error().Err(err).Str("owner_id", req.OwnerId).Msg("failed to list saved searches") + return nil, status.Errorf(codes.Internal, "failed to list saved searches: %v", err) + } + + var protoSearches []*gen.SavedSearch + for _, search := range result.SavedSearches { + protoSearch, err := transformers.SavedSearchTypeToProto(search) + if err != nil { + log.Error().Err(err).Str("id", search.ID).Msg("failed to convert saved search to proto") + continue + } + protoSearches = append(protoSearches, protoSearch) + } + + return &gen.ListSavedSearchesResponse{ + SavedSearches: protoSearches, + Total: result.Total, + Limit: int32(result.Limit), + Offset: int32(result.Offset), + }, nil +} + +// Run starts the gRPC server following solidarity transport pattern +func Run(done chan error, cfg *viper.Viper, savedSearchService *service.SavedSearchService) { + var ( + dev_env = cfg.GetBool("dev_env") + address = ":" + cfg.GetString("services.grpc.port") + ) + + server := grpc.NewServer() + + gen.RegisterSavedSearchServiceServer(server, NewSavedSearchServerImpl(savedSearchService)) + l, err := net.Listen("tcp", address) + if err != nil { + log.Fatal().Err(err).Msg("could not register saved search grpc server") + return + } + + if dev_env { + reflection.Register(server) + } + + if err := server.Serve(l); err != nil { + fmt.Println("gRPC service ended") + done <- err + } +} \ No newline at end of file diff --git a/servers/grpc/transformers/transformers.go b/servers/grpc/transformers/transformers.go new file mode 100644 index 0000000..c916ba4 --- /dev/null +++ b/servers/grpc/transformers/transformers.go @@ -0,0 +1,116 @@ +package transformers + +import ( + "encoding/json" + "fmt" + "time" + + "git.coopgo.io/coopgo-platform/saved-search/data/types" + "git.coopgo.io/coopgo-platform/saved-search/servers/grpc/proto/gen" + "github.com/paulmach/orb/geojson" + "google.golang.org/protobuf/types/known/structpb" + "google.golang.org/protobuf/types/known/timestamppb" +) + +// SavedSearchTypeToProto converts a domain SavedSearch to protobuf SavedSearch +func SavedSearchTypeToProto(search *types.SavedSearch) (*gen.SavedSearch, error) { + if search == nil { + return nil, fmt.Errorf("search cannot be nil") + } + + departure, err := GeoJsonFeatureToProto(search.Departure) + if err != nil { + return nil, fmt.Errorf("failed to convert departure: %w", err) + } + + destination, err := GeoJsonFeatureToProto(search.Destination) + if err != nil { + return nil, fmt.Errorf("failed to convert destination: %w", err) + } + + data, err := structpb.NewStruct(search.Data) + if err != nil { + return nil, fmt.Errorf("failed to convert data: %w", err) + } + + return &gen.SavedSearch{ + Id: search.ID, + OwnerId: search.OwnerID, + Departure: departure, + Destination: destination, + Datetime: timestamppb.New(search.DateTime), + Data: data, + CreatedAt: timestamppb.New(search.CreatedAt), + UpdatedAt: timestamppb.New(search.UpdatedAt), + }, nil +} + +// SavedSearchProtoToType converts a protobuf SavedSearch to domain SavedSearch +func SavedSearchProtoToType(search *gen.SavedSearch) (*types.SavedSearch, error) { + if search == nil { + return nil, fmt.Errorf("search cannot be nil") + } + + departure, err := GeoJsonFeatureFromProto(search.Departure) + if err != nil { + return nil, fmt.Errorf("failed to convert departure: %w", err) + } + + destination, err := GeoJsonFeatureFromProto(search.Destination) + if err != nil { + return nil, fmt.Errorf("failed to convert destination: %w", err) + } + + var data map[string]interface{} + if search.Data != nil { + data = search.Data.AsMap() + } else { + data = make(map[string]interface{}) + } + + var datetime time.Time + if search.Datetime != nil { + datetime = search.Datetime.AsTime() + } + + return &types.SavedSearch{ + ID: search.Id, + OwnerID: search.OwnerId, + Departure: departure, + Destination: destination, + DateTime: datetime, + Data: data, + CreatedAt: search.CreatedAt.AsTime(), + UpdatedAt: search.UpdatedAt.AsTime(), + }, nil +} + +// GeoJsonFeatureToProto converts a GeoJSON Feature to protobuf SavedSearchGeoJsonFeature +func GeoJsonFeatureToProto(feature *geojson.Feature) (*gen.SavedSearchGeoJsonFeature, error) { + if feature == nil { + return nil, fmt.Errorf("feature cannot be nil") + } + + serialized, err := json.Marshal(feature) + if err != nil { + return nil, fmt.Errorf("failed to serialize feature: %w", err) + } + + return &gen.SavedSearchGeoJsonFeature{ + Serialized: string(serialized), + }, nil +} + +// GeoJsonFeatureFromProto converts a protobuf SavedSearchGeoJsonFeature to GeoJSON Feature +func GeoJsonFeatureFromProto(protoFeature *gen.SavedSearchGeoJsonFeature) (*geojson.Feature, error) { + if protoFeature == nil { + return nil, fmt.Errorf("proto feature cannot be nil") + } + + var feature geojson.Feature + if err := json.Unmarshal([]byte(protoFeature.Serialized), &feature); err != nil { + return nil, fmt.Errorf("failed to deserialize feature: %w", err) + } + + return &feature, nil +} \ No newline at end of file