Skip to content

Commit

Permalink
Feature: Subscription expiration policy (#373)
Browse files Browse the repository at this point in the history
  • Loading branch information
ext-devgangavkar authored Feb 27, 2024
1 parent 78fd272 commit aac26e0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/resources/streaming_namespace.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ Optional:
- `schema_auto_update_compatibility_strategy` (String)
- `schema_compatibility_strategy` (String)
- `schema_validation_enforced` (Boolean)
- `subscription_expiration_time_minutes` (Number)

<a id="nestedatt--policies--auto_topic_creation_override"></a>
### Nested Schema for `policies.auto_topic_creation_override`
Expand Down
16 changes: 12 additions & 4 deletions internal/provider/types_streaming_namespace_policies.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const (
policyInactiveTopicDeleteWhileInactive = "delete_while_inactive"
policyInactiveTopicMaxInactiveDurationSeconds = "max_inactive_duration_seconds"
policyInactiveTopicDeleteMode = "delete_mode"

policySubscriptionExpirationTimeMinutes = "subscription_expiration_time_minutes"
)

type PulsarNamespacePolicies struct {
Expand All @@ -58,10 +60,11 @@ type PulsarNamespacePolicies struct {
SchemaCompatibilityStrategy *string `tfsdk:"schema_compatibility_strategy" json:"schema_compatibility_strategy,omitempty"`
SchemaValidationEnforced *bool `tfsdk:"schema_validation_enforced" json:"schema_validation_enforced,omitempty"`

AutoTopicCreationOverride *PulsarNamespaceAutoTopicCreationOverride `tfsdk:"auto_topic_creation_override" json:"autoTopicCreationOverride,omitempty"`
BacklogQuota map[string]*PulsarNamespaceBacklogQuota `tfsdk:"backlog_quota_map" json:"backlog_quota_map,omitempty"`
RetentionPolicies *PulsarNamespaceRetentionPolicies `tfsdk:"retention_policies" json:"retention_policies,omitempty"`
InactiveTopicPolicies *PulsarNamespaceInactiveTopicPolicies `tfsdk:"inactive_topic_policies" json:"inactive_topic_policies,omitempty"`
AutoTopicCreationOverride *PulsarNamespaceAutoTopicCreationOverride `tfsdk:"auto_topic_creation_override" json:"autoTopicCreationOverride,omitempty"`
BacklogQuota map[string]*PulsarNamespaceBacklogQuota `tfsdk:"backlog_quota_map" json:"backlog_quota_map,omitempty"`
RetentionPolicies *PulsarNamespaceRetentionPolicies `tfsdk:"retention_policies" json:"retention_policies,omitempty"`
InactiveTopicPolicies *PulsarNamespaceInactiveTopicPolicies `tfsdk:"inactive_topic_policies" json:"inactive_topic_policies,omitempty"`
SubscriptionExpirationTimeMinutes *int64 `tfsdk:"subscription_expiration_time_minutes" json:"subscription_expiration_time_minutes,omitempty"`
}

type PulsarNamespaceRetentionPolicies struct {
Expand Down Expand Up @@ -195,6 +198,7 @@ var (
policyInactiveTopicMaxInactiveDurationSeconds: int64PulsarNamespacePolicyAttribute,
},
},
policySubscriptionExpirationTimeMinutes: int64PulsarNamespacePolicyAttribute,
},
}
)
Expand Down Expand Up @@ -335,6 +339,10 @@ func setNamespacePolicies(ctx context.Context, client *pulsaradmin.ClientWithRes
resp, err := client.NamespacesSetInactiveTopicPolicies(ctx, tenant, namespace, *policies.InactiveTopicPolicies, requestEditors...)
diags.Append(HTTPResponseDiagWarn(resp, err, pulsarNamespacePolicyError(policyInactiveTopicPolicies))...)
}
if policies.SubscriptionExpirationTimeMinutes != nil {
resp, err := client.NamespacesSetSubscriptionExpirationTime(ctx, tenant, namespace, *policies.SubscriptionExpirationTimeMinutes, requestEditors...)
diags.Append(HTTPResponseDiagWarn(resp, err, pulsarNamespacePolicyError(policySubscriptionExpirationTimeMinutes))...)
}
return diags
}

Expand Down

0 comments on commit aac26e0

Please sign in to comment.