go.temporal.io/server@v1.23.0/common/persistence/sql/sqlplugin/matching_task_queue.go (about) 1 // The MIT License 2 // 3 // Copyright (c) 2020 Temporal Technologies Inc. All rights reserved. 4 // 5 // Copyright (c) 2020 Uber Technologies, Inc. 6 // 7 // Permission is hereby granted, free of charge, to any person obtaining a copy 8 // of this software and associated documentation files (the "Software"), to deal 9 // in the Software without restriction, including without limitation the rights 10 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 // copies of the Software, and to permit persons to whom the Software is 12 // furnished to do so, subject to the following conditions: 13 // 14 // The above copyright notice and this permission notice shall be included in 15 // all copies or substantial portions of the Software. 16 // 17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 // THE SOFTWARE. 24 25 package sqlplugin 26 27 import ( 28 "context" 29 "database/sql" 30 ) 31 32 type ( 33 // TaskQueuesRow represents a row in task_queues table 34 TaskQueuesRow struct { 35 RangeHash uint32 36 TaskQueueID []byte 37 RangeID int64 38 Data []byte 39 DataEncoding string 40 } 41 42 // TaskQueuesFilter contains the column names within task_queues table that 43 // can be used to filter results through a WHERE clause 44 TaskQueuesFilter struct { 45 RangeHash uint32 46 RangeHashGreaterThanEqualTo uint32 47 RangeHashLessThanEqualTo uint32 48 TaskQueueID []byte 49 TaskQueueIDGreaterThan []byte 50 RangeID *int64 51 PageSize *int 52 } 53 54 GetTaskQueueUserDataRequest struct { 55 NamespaceID []byte 56 TaskQueueName string 57 } 58 59 UpdateTaskQueueDataRequest struct { 60 NamespaceID []byte 61 TaskQueueName string 62 Version int64 63 Data []byte 64 DataEncoding string 65 } 66 67 AddToBuildIdToTaskQueueMapping struct { 68 NamespaceID []byte 69 TaskQueueName string 70 BuildIds []string 71 } 72 73 RemoveFromBuildIdToTaskQueueMapping struct { 74 NamespaceID []byte 75 TaskQueueName string 76 BuildIds []string 77 } 78 79 GetTaskQueuesByBuildIdRequest struct { 80 NamespaceID []byte 81 BuildID string 82 } 83 84 CountTaskQueuesByBuildIdRequest struct { 85 NamespaceID []byte 86 BuildID string 87 } 88 89 VersionedBlob struct { 90 Version int64 91 Data []byte 92 DataEncoding string 93 } 94 95 ListTaskQueueUserDataEntriesRequest struct { 96 NamespaceID []byte 97 LastTaskQueueName string 98 Limit int 99 } 100 101 TaskQueueUserDataEntry struct { 102 TaskQueueName string 103 VersionedBlob 104 } 105 106 // MatchingTaskQueue is the SQL persistence interface for matching task queues 107 MatchingTaskQueue interface { 108 InsertIntoTaskQueues(ctx context.Context, row *TaskQueuesRow) (sql.Result, error) 109 UpdateTaskQueues(ctx context.Context, row *TaskQueuesRow) (sql.Result, error) 110 // SelectFromTaskQueues returns one or more rows from task_queues table 111 // Required Filter params: 112 // to read a single row: {shardID, namespaceID, name, taskType} 113 // to range read multiple rows: {shardID, namespaceIDGreaterThan, nameGreaterThan, taskTypeGreaterThan, pageSize} 114 SelectFromTaskQueues(ctx context.Context, filter TaskQueuesFilter) ([]TaskQueuesRow, error) 115 DeleteFromTaskQueues(ctx context.Context, filter TaskQueuesFilter) (sql.Result, error) 116 LockTaskQueues(ctx context.Context, filter TaskQueuesFilter) (int64, error) 117 GetTaskQueueUserData(ctx context.Context, request *GetTaskQueueUserDataRequest) (*VersionedBlob, error) 118 UpdateTaskQueueUserData(ctx context.Context, request *UpdateTaskQueueDataRequest) error 119 AddToBuildIdToTaskQueueMapping(ctx context.Context, request AddToBuildIdToTaskQueueMapping) error 120 RemoveFromBuildIdToTaskQueueMapping(ctx context.Context, request RemoveFromBuildIdToTaskQueueMapping) error 121 ListTaskQueueUserDataEntries(ctx context.Context, request *ListTaskQueueUserDataEntriesRequest) ([]TaskQueueUserDataEntry, error) 122 GetTaskQueuesByBuildId(ctx context.Context, request *GetTaskQueuesByBuildIdRequest) ([]string, error) 123 CountTaskQueuesByBuildId(ctx context.Context, request *CountTaskQueuesByBuildIdRequest) (int, error) 124 } 125 )