@@ -442,73 +442,52 @@ const (
442442 TimeToLiveModeValueSinceUnixEpoch
443443)
444444
445- func (ttl TimeToLiveSettings ) WithColumnName (columnName string ) TimeToLiveSettings {
446- ttl .ColumnName = columnName
447- return ttl
448- }
449-
450- func (ttl TimeToLiveSettings ) ExpireAfter (expireAfter time.Duration ) TimeToLiveSettings {
451- ttl .ExpireAfterSeconds = uint32 (expireAfter .Seconds ())
452- return ttl
453- }
454-
455- func (ttl TimeToLiveSettings ) WithMode (mode TimeToLiveMode ) TimeToLiveSettings {
456- ttl .Mode = mode
457- return ttl
445+ func NewTTLSettings () TimeToLiveSettings {
446+ return TimeToLiveSettings {
447+ Mode : TimeToLiveModeDateType ,
448+ }
458449}
459450
460- func (ttl TimeToLiveSettings ) ModeDate ( ) TimeToLiveSettings {
451+ func (ttl TimeToLiveSettings ) ColumnDateType ( columnName string ) TimeToLiveSettings {
461452 ttl .Mode = TimeToLiveModeDateType
462- ttl .ColumnUnit = nil
453+ ttl .ColumnName = columnName
463454 return ttl
464455}
465456
466- func (ttl TimeToLiveSettings ) ModeSinceEpoch () TimeToLiveSettings {
467- ttl .Mode = TimeToLiveModeValueSinceUnixEpoch
468- if ttl .ColumnUnit == nil {
469- return ttl .ColumnUnitSeconds ()
470- }
471- return ttl
457+ func unitToPointer (unit TimeToLiveUnit ) * TimeToLiveUnit {
458+ return & unit
472459}
473460
474- func (ttl TimeToLiveSettings ) WithColumnUnit (columnUnit TimeToLiveUnit ) TimeToLiveSettings {
475- ttl .ColumnUnit = & columnUnit
461+ func (ttl TimeToLiveSettings ) ColumnSeconds (columnName string ) TimeToLiveSettings {
462+ ttl .Mode = TimeToLiveModeValueSinceUnixEpoch
463+ ttl .ColumnName = columnName
464+ ttl .ColumnUnit = unitToPointer (TimeToLiveUnitSeconds )
476465 return ttl
477466}
478467
479- func (ttl TimeToLiveSettings ) ColumnUnitSeconds () TimeToLiveSettings {
480- if ttl .Mode != TimeToLiveModeValueSinceUnixEpoch {
481- ttl .Mode = TimeToLiveModeValueSinceUnixEpoch
482- }
483- columnUnit := TimeToLiveUnitSeconds
484- ttl .ColumnUnit = & columnUnit
468+ func (ttl TimeToLiveSettings ) ColumnMilliseconds (columnName string ) TimeToLiveSettings {
469+ ttl .Mode = TimeToLiveModeValueSinceUnixEpoch
470+ ttl .ColumnName = columnName
471+ ttl .ColumnUnit = unitToPointer (TimeToLiveUnitMilliseconds )
485472 return ttl
486473}
487474
488- func (ttl TimeToLiveSettings ) ColumnUnitMilliseconds () TimeToLiveSettings {
489- if ttl .Mode != TimeToLiveModeValueSinceUnixEpoch {
490- ttl .Mode = TimeToLiveModeValueSinceUnixEpoch
491- }
492- columnUnit := TimeToLiveUnitMilliseconds
493- ttl .ColumnUnit = & columnUnit
475+ func (ttl TimeToLiveSettings ) ColumnMicroseconds (columnName string ) TimeToLiveSettings {
476+ ttl .Mode = TimeToLiveModeValueSinceUnixEpoch
477+ ttl .ColumnName = columnName
478+ ttl .ColumnUnit = unitToPointer (TimeToLiveUnitMicroseconds )
494479 return ttl
495480}
496481
497- func (ttl TimeToLiveSettings ) ColumnUnitMicroseconds () TimeToLiveSettings {
498- if ttl .Mode != TimeToLiveModeValueSinceUnixEpoch {
499- ttl .Mode = TimeToLiveModeValueSinceUnixEpoch
500- }
501- columnUnit := TimeToLiveUnitMicroseconds
502- ttl .ColumnUnit = & columnUnit
482+ func (ttl TimeToLiveSettings ) ColumnNanoseconds (columnName string ) TimeToLiveSettings {
483+ ttl .Mode = TimeToLiveModeValueSinceUnixEpoch
484+ ttl .ColumnName = columnName
485+ ttl .ColumnUnit = unitToPointer (TimeToLiveUnitNanoseconds )
503486 return ttl
504487}
505488
506- func (ttl TimeToLiveSettings ) ColumnUnitNanoseconds () TimeToLiveSettings {
507- if ttl .Mode != TimeToLiveModeValueSinceUnixEpoch {
508- ttl .Mode = TimeToLiveModeValueSinceUnixEpoch
509- }
510- columnUnit := TimeToLiveUnitNanoseconds
511- ttl .ColumnUnit = & columnUnit
489+ func (ttl TimeToLiveSettings ) ExpireAfter (expireAfter time.Duration ) TimeToLiveSettings {
490+ ttl .ExpireAfterSeconds = uint32 (expireAfter .Seconds ())
512491 return ttl
513492}
514493
@@ -539,29 +518,6 @@ func (ttl *TimeToLiveSettings) ToYDB() *Ydb_Table.TtlSettings {
539518 }
540519}
541520
542- func NewTimeToLiveSettings (settings * Ydb_Table.TtlSettings ) * TimeToLiveSettings {
543- if settings == nil {
544- return nil
545- }
546- switch mode := settings .Mode .(type ) {
547- case * Ydb_Table.TtlSettings_DateTypeColumn :
548- return & TimeToLiveSettings {
549- ColumnName : mode .DateTypeColumn .ColumnName ,
550- ExpireAfterSeconds : mode .DateTypeColumn .ExpireAfterSeconds ,
551- Mode : TimeToLiveModeDateType ,
552- }
553-
554- case * Ydb_Table.TtlSettings_ValueSinceUnixEpoch :
555- return & TimeToLiveSettings {
556- ColumnName : mode .ValueSinceUnixEpoch .ColumnName ,
557- ColumnUnit : timeToLiveUnit (mode .ValueSinceUnixEpoch .ColumnUnit ),
558- ExpireAfterSeconds : mode .ValueSinceUnixEpoch .ExpireAfterSeconds ,
559- Mode : TimeToLiveModeValueSinceUnixEpoch ,
560- }
561- }
562- return nil
563- }
564-
565521type TimeToLiveUnit int32
566522
567523const (
@@ -592,25 +548,6 @@ func (unit *TimeToLiveUnit) ToYDB() Ydb_Table.ValueSinceUnixEpochModeSettings_Un
592548 }
593549}
594550
595- func timeToLiveUnit (unit Ydb_Table.ValueSinceUnixEpochModeSettings_Unit ) * TimeToLiveUnit {
596- var res TimeToLiveUnit
597- switch unit {
598- case Ydb_Table .ValueSinceUnixEpochModeSettings_UNIT_SECONDS :
599- res = TimeToLiveUnitSeconds
600- case Ydb_Table .ValueSinceUnixEpochModeSettings_UNIT_MILLISECONDS :
601- res = TimeToLiveUnitMilliseconds
602- case Ydb_Table .ValueSinceUnixEpochModeSettings_UNIT_MICROSECONDS :
603- res = TimeToLiveUnitMicroseconds
604- case Ydb_Table .ValueSinceUnixEpochModeSettings_UNIT_NANOSECONDS :
605- res = TimeToLiveUnitNanoseconds
606- case Ydb_Table .ValueSinceUnixEpochModeSettings_UNIT_UNSPECIFIED :
607- res = TimeToLiveUnitUnspecified
608- default :
609- panic ("ydb: unknown Ydb unit for value since epoch" )
610- }
611- return & res
612- }
613-
614551type ChangefeedDescription struct {
615552 Name string
616553 Mode ChangefeedMode
0 commit comments