Skip to content

Commit

Permalink
Datastream - Add mysql backfill max tasks (#7924) (#5648)
Browse files Browse the repository at this point in the history
* Add mysql backfill max tasks

* Add mysql backfill max tasks to tests

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored May 17, 2023
1 parent 4dc3146 commit 1be370c
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/7924.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
datastream: added `mysql_source_config.max_concurrent_backfill_tasks` field to `google_datastream_stream` resource
```
38 changes: 38 additions & 0 deletions google-beta/resource_datastream_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,14 @@ https://dev.mysql.com/doc/refman/8.0/en/data-types.html`,
},
},
},
"max_concurrent_backfill_tasks": {
Type: schema.TypeInt,
Computed: true,
Optional: true,
ValidateFunc: validation.IntAtLeast(0),
Description: `Maximum number of concurrent backfill tasks. The number should be non negative.
If not set (or set to 0), the system's default value will be used.`,
},
"max_concurrent_cdc_tasks": {
Type: schema.TypeInt,
Computed: true,
Expand Down Expand Up @@ -1741,6 +1749,8 @@ func flattenDatastreamStreamSourceConfigMysqlSourceConfig(v interface{}, d *sche
flattenDatastreamStreamSourceConfigMysqlSourceConfigExcludeObjects(original["excludeObjects"], d, config)
transformed["max_concurrent_cdc_tasks"] =
flattenDatastreamStreamSourceConfigMysqlSourceConfigMaxConcurrentCdcTasks(original["maxConcurrentCdcTasks"], d, config)
transformed["max_concurrent_backfill_tasks"] =
flattenDatastreamStreamSourceConfigMysqlSourceConfigMaxConcurrentBackfillTasks(original["maxConcurrentBackfillTasks"], d, config)
return []interface{}{transformed}
}
func flattenDatastreamStreamSourceConfigMysqlSourceConfigIncludeObjects(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
Expand Down Expand Up @@ -2034,6 +2044,23 @@ func flattenDatastreamStreamSourceConfigMysqlSourceConfigMaxConcurrentCdcTasks(v
return v // let terraform core handle it otherwise
}

func flattenDatastreamStreamSourceConfigMysqlSourceConfigMaxConcurrentBackfillTasks(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
// Handles the string fixed64 format
if strVal, ok := v.(string); ok {
if intVal, err := StringToFixed64(strVal); err == nil {
return intVal
}
}

// number values are represented as float64
if floatVal, ok := v.(float64); ok {
intVal := int(floatVal)
return intVal
}

return v // let terraform core handle it otherwise
}

func flattenDatastreamStreamSourceConfigOracleSourceConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
if v == nil {
return nil
Expand Down Expand Up @@ -3609,6 +3636,13 @@ func expandDatastreamStreamSourceConfigMysqlSourceConfig(v interface{}, d tpgres
transformed["maxConcurrentCdcTasks"] = transformedMaxConcurrentCdcTasks
}

transformedMaxConcurrentBackfillTasks, err := expandDatastreamStreamSourceConfigMysqlSourceConfigMaxConcurrentBackfillTasks(original["max_concurrent_backfill_tasks"], d, config)
if err != nil {
return nil, err
} else {
transformed["maxConcurrentBackfillTasks"] = transformedMaxConcurrentBackfillTasks
}

return transformed, nil
}

Expand Down Expand Up @@ -3970,6 +4004,10 @@ func expandDatastreamStreamSourceConfigMysqlSourceConfigMaxConcurrentCdcTasks(v
return v, nil
}

func expandDatastreamStreamSourceConfigMysqlSourceConfigMaxConcurrentBackfillTasks(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func expandDatastreamStreamSourceConfigOracleSourceConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 {
Expand Down
4 changes: 3 additions & 1 deletion google-beta/resource_datastream_stream_generated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ resource "google_datastream_stream" "default" {
display_name = "my stream"
source_config {
source_connection_profile = google_datastream_connection_profile.source_connection_profile.id
mysql_source_config {}
mysql_source_config {
max_concurrent_backfill_tasks = 15
}
}
destination_config {
destination_connection_profile = google_datastream_connection_profile.destination_connection_profile.id
Expand Down
5 changes: 5 additions & 0 deletions website/docs/r/datastream_stream.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,11 @@ The following arguments are supported:
Maximum number of concurrent CDC tasks. The number should be non negative.
If not set (or set to 0), the system's default value will be used.

* `max_concurrent_backfill_tasks` -
(Optional)
Maximum number of concurrent backfill tasks. The number should be non negative.
If not set (or set to 0), the system's default value will be used.


<a name="nested_include_objects"></a>The `include_objects` block supports:

Expand Down

0 comments on commit 1be370c

Please sign in to comment.