1// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2// See LICENSE.txt for license information. 3 4// Code generated by "make store-layers" 5// DO NOT EDIT 6 7package retrylayer 8 9import ( 10 "context" 11 12 "github.com/go-sql-driver/mysql" 13 "github.com/lib/pq" 14 "github.com/mattermost/mattermost-server/v6/model" 15 "github.com/mattermost/mattermost-server/v6/store" 16 "github.com/pkg/errors" 17) 18 19const mySQLDeadlockCode = uint16(1213) 20 21type RetryLayer struct { 22 store.Store 23 AuditStore store.AuditStore 24 BotStore store.BotStore 25 ChannelStore store.ChannelStore 26 ChannelMemberHistoryStore store.ChannelMemberHistoryStore 27 ClusterDiscoveryStore store.ClusterDiscoveryStore 28 CommandStore store.CommandStore 29 CommandWebhookStore store.CommandWebhookStore 30 ComplianceStore store.ComplianceStore 31 EmojiStore store.EmojiStore 32 FileInfoStore store.FileInfoStore 33 GroupStore store.GroupStore 34 JobStore store.JobStore 35 LicenseStore store.LicenseStore 36 LinkMetadataStore store.LinkMetadataStore 37 OAuthStore store.OAuthStore 38 PluginStore store.PluginStore 39 PostStore store.PostStore 40 PreferenceStore store.PreferenceStore 41 ProductNoticesStore store.ProductNoticesStore 42 ReactionStore store.ReactionStore 43 RemoteClusterStore store.RemoteClusterStore 44 RetentionPolicyStore store.RetentionPolicyStore 45 RoleStore store.RoleStore 46 SchemeStore store.SchemeStore 47 SessionStore store.SessionStore 48 SharedChannelStore store.SharedChannelStore 49 StatusStore store.StatusStore 50 SystemStore store.SystemStore 51 TeamStore store.TeamStore 52 TermsOfServiceStore store.TermsOfServiceStore 53 ThreadStore store.ThreadStore 54 TokenStore store.TokenStore 55 UploadSessionStore store.UploadSessionStore 56 UserStore store.UserStore 57 UserAccessTokenStore store.UserAccessTokenStore 58 UserTermsOfServiceStore store.UserTermsOfServiceStore 59 WebhookStore store.WebhookStore 60} 61 62func (s *RetryLayer) Audit() store.AuditStore { 63 return s.AuditStore 64} 65 66func (s *RetryLayer) Bot() store.BotStore { 67 return s.BotStore 68} 69 70func (s *RetryLayer) Channel() store.ChannelStore { 71 return s.ChannelStore 72} 73 74func (s *RetryLayer) ChannelMemberHistory() store.ChannelMemberHistoryStore { 75 return s.ChannelMemberHistoryStore 76} 77 78func (s *RetryLayer) ClusterDiscovery() store.ClusterDiscoveryStore { 79 return s.ClusterDiscoveryStore 80} 81 82func (s *RetryLayer) Command() store.CommandStore { 83 return s.CommandStore 84} 85 86func (s *RetryLayer) CommandWebhook() store.CommandWebhookStore { 87 return s.CommandWebhookStore 88} 89 90func (s *RetryLayer) Compliance() store.ComplianceStore { 91 return s.ComplianceStore 92} 93 94func (s *RetryLayer) Emoji() store.EmojiStore { 95 return s.EmojiStore 96} 97 98func (s *RetryLayer) FileInfo() store.FileInfoStore { 99 return s.FileInfoStore 100} 101 102func (s *RetryLayer) Group() store.GroupStore { 103 return s.GroupStore 104} 105 106func (s *RetryLayer) Job() store.JobStore { 107 return s.JobStore 108} 109 110func (s *RetryLayer) License() store.LicenseStore { 111 return s.LicenseStore 112} 113 114func (s *RetryLayer) LinkMetadata() store.LinkMetadataStore { 115 return s.LinkMetadataStore 116} 117 118func (s *RetryLayer) OAuth() store.OAuthStore { 119 return s.OAuthStore 120} 121 122func (s *RetryLayer) Plugin() store.PluginStore { 123 return s.PluginStore 124} 125 126func (s *RetryLayer) Post() store.PostStore { 127 return s.PostStore 128} 129 130func (s *RetryLayer) Preference() store.PreferenceStore { 131 return s.PreferenceStore 132} 133 134func (s *RetryLayer) ProductNotices() store.ProductNoticesStore { 135 return s.ProductNoticesStore 136} 137 138func (s *RetryLayer) Reaction() store.ReactionStore { 139 return s.ReactionStore 140} 141 142func (s *RetryLayer) RemoteCluster() store.RemoteClusterStore { 143 return s.RemoteClusterStore 144} 145 146func (s *RetryLayer) RetentionPolicy() store.RetentionPolicyStore { 147 return s.RetentionPolicyStore 148} 149 150func (s *RetryLayer) Role() store.RoleStore { 151 return s.RoleStore 152} 153 154func (s *RetryLayer) Scheme() store.SchemeStore { 155 return s.SchemeStore 156} 157 158func (s *RetryLayer) Session() store.SessionStore { 159 return s.SessionStore 160} 161 162func (s *RetryLayer) SharedChannel() store.SharedChannelStore { 163 return s.SharedChannelStore 164} 165 166func (s *RetryLayer) Status() store.StatusStore { 167 return s.StatusStore 168} 169 170func (s *RetryLayer) System() store.SystemStore { 171 return s.SystemStore 172} 173 174func (s *RetryLayer) Team() store.TeamStore { 175 return s.TeamStore 176} 177 178func (s *RetryLayer) TermsOfService() store.TermsOfServiceStore { 179 return s.TermsOfServiceStore 180} 181 182func (s *RetryLayer) Thread() store.ThreadStore { 183 return s.ThreadStore 184} 185 186func (s *RetryLayer) Token() store.TokenStore { 187 return s.TokenStore 188} 189 190func (s *RetryLayer) UploadSession() store.UploadSessionStore { 191 return s.UploadSessionStore 192} 193 194func (s *RetryLayer) User() store.UserStore { 195 return s.UserStore 196} 197 198func (s *RetryLayer) UserAccessToken() store.UserAccessTokenStore { 199 return s.UserAccessTokenStore 200} 201 202func (s *RetryLayer) UserTermsOfService() store.UserTermsOfServiceStore { 203 return s.UserTermsOfServiceStore 204} 205 206func (s *RetryLayer) Webhook() store.WebhookStore { 207 return s.WebhookStore 208} 209 210type RetryLayerAuditStore struct { 211 store.AuditStore 212 Root *RetryLayer 213} 214 215type RetryLayerBotStore struct { 216 store.BotStore 217 Root *RetryLayer 218} 219 220type RetryLayerChannelStore struct { 221 store.ChannelStore 222 Root *RetryLayer 223} 224 225type RetryLayerChannelMemberHistoryStore struct { 226 store.ChannelMemberHistoryStore 227 Root *RetryLayer 228} 229 230type RetryLayerClusterDiscoveryStore struct { 231 store.ClusterDiscoveryStore 232 Root *RetryLayer 233} 234 235type RetryLayerCommandStore struct { 236 store.CommandStore 237 Root *RetryLayer 238} 239 240type RetryLayerCommandWebhookStore struct { 241 store.CommandWebhookStore 242 Root *RetryLayer 243} 244 245type RetryLayerComplianceStore struct { 246 store.ComplianceStore 247 Root *RetryLayer 248} 249 250type RetryLayerEmojiStore struct { 251 store.EmojiStore 252 Root *RetryLayer 253} 254 255type RetryLayerFileInfoStore struct { 256 store.FileInfoStore 257 Root *RetryLayer 258} 259 260type RetryLayerGroupStore struct { 261 store.GroupStore 262 Root *RetryLayer 263} 264 265type RetryLayerJobStore struct { 266 store.JobStore 267 Root *RetryLayer 268} 269 270type RetryLayerLicenseStore struct { 271 store.LicenseStore 272 Root *RetryLayer 273} 274 275type RetryLayerLinkMetadataStore struct { 276 store.LinkMetadataStore 277 Root *RetryLayer 278} 279 280type RetryLayerOAuthStore struct { 281 store.OAuthStore 282 Root *RetryLayer 283} 284 285type RetryLayerPluginStore struct { 286 store.PluginStore 287 Root *RetryLayer 288} 289 290type RetryLayerPostStore struct { 291 store.PostStore 292 Root *RetryLayer 293} 294 295type RetryLayerPreferenceStore struct { 296 store.PreferenceStore 297 Root *RetryLayer 298} 299 300type RetryLayerProductNoticesStore struct { 301 store.ProductNoticesStore 302 Root *RetryLayer 303} 304 305type RetryLayerReactionStore struct { 306 store.ReactionStore 307 Root *RetryLayer 308} 309 310type RetryLayerRemoteClusterStore struct { 311 store.RemoteClusterStore 312 Root *RetryLayer 313} 314 315type RetryLayerRetentionPolicyStore struct { 316 store.RetentionPolicyStore 317 Root *RetryLayer 318} 319 320type RetryLayerRoleStore struct { 321 store.RoleStore 322 Root *RetryLayer 323} 324 325type RetryLayerSchemeStore struct { 326 store.SchemeStore 327 Root *RetryLayer 328} 329 330type RetryLayerSessionStore struct { 331 store.SessionStore 332 Root *RetryLayer 333} 334 335type RetryLayerSharedChannelStore struct { 336 store.SharedChannelStore 337 Root *RetryLayer 338} 339 340type RetryLayerStatusStore struct { 341 store.StatusStore 342 Root *RetryLayer 343} 344 345type RetryLayerSystemStore struct { 346 store.SystemStore 347 Root *RetryLayer 348} 349 350type RetryLayerTeamStore struct { 351 store.TeamStore 352 Root *RetryLayer 353} 354 355type RetryLayerTermsOfServiceStore struct { 356 store.TermsOfServiceStore 357 Root *RetryLayer 358} 359 360type RetryLayerThreadStore struct { 361 store.ThreadStore 362 Root *RetryLayer 363} 364 365type RetryLayerTokenStore struct { 366 store.TokenStore 367 Root *RetryLayer 368} 369 370type RetryLayerUploadSessionStore struct { 371 store.UploadSessionStore 372 Root *RetryLayer 373} 374 375type RetryLayerUserStore struct { 376 store.UserStore 377 Root *RetryLayer 378} 379 380type RetryLayerUserAccessTokenStore struct { 381 store.UserAccessTokenStore 382 Root *RetryLayer 383} 384 385type RetryLayerUserTermsOfServiceStore struct { 386 store.UserTermsOfServiceStore 387 Root *RetryLayer 388} 389 390type RetryLayerWebhookStore struct { 391 store.WebhookStore 392 Root *RetryLayer 393} 394 395func isRepeatableError(err error) bool { 396 var pqErr *pq.Error 397 var mysqlErr *mysql.MySQLError 398 switch { 399 case errors.As(errors.Cause(err), &pqErr): 400 if pqErr.Code == "40001" || pqErr.Code == "40P01" { 401 return true 402 } 403 case errors.As(errors.Cause(err), &mysqlErr): 404 if mysqlErr.Number == mySQLDeadlockCode { 405 return true 406 } 407 } 408 return false 409} 410 411func (s *RetryLayerAuditStore) Get(user_id string, offset int, limit int) (model.Audits, error) { 412 413 tries := 0 414 for { 415 result, err := s.AuditStore.Get(user_id, offset, limit) 416 if err == nil { 417 return result, nil 418 } 419 if !isRepeatableError(err) { 420 return result, err 421 } 422 tries++ 423 if tries >= 3 { 424 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 425 return result, err 426 } 427 } 428 429} 430 431func (s *RetryLayerAuditStore) PermanentDeleteByUser(userID string) error { 432 433 tries := 0 434 for { 435 err := s.AuditStore.PermanentDeleteByUser(userID) 436 if err == nil { 437 return nil 438 } 439 if !isRepeatableError(err) { 440 return err 441 } 442 tries++ 443 if tries >= 3 { 444 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 445 return err 446 } 447 } 448 449} 450 451func (s *RetryLayerAuditStore) Save(audit *model.Audit) error { 452 453 tries := 0 454 for { 455 err := s.AuditStore.Save(audit) 456 if err == nil { 457 return nil 458 } 459 if !isRepeatableError(err) { 460 return err 461 } 462 tries++ 463 if tries >= 3 { 464 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 465 return err 466 } 467 } 468 469} 470 471func (s *RetryLayerBotStore) Get(userID string, includeDeleted bool) (*model.Bot, error) { 472 473 tries := 0 474 for { 475 result, err := s.BotStore.Get(userID, includeDeleted) 476 if err == nil { 477 return result, nil 478 } 479 if !isRepeatableError(err) { 480 return result, err 481 } 482 tries++ 483 if tries >= 3 { 484 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 485 return result, err 486 } 487 } 488 489} 490 491func (s *RetryLayerBotStore) GetAll(options *model.BotGetOptions) ([]*model.Bot, error) { 492 493 tries := 0 494 for { 495 result, err := s.BotStore.GetAll(options) 496 if err == nil { 497 return result, nil 498 } 499 if !isRepeatableError(err) { 500 return result, err 501 } 502 tries++ 503 if tries >= 3 { 504 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 505 return result, err 506 } 507 } 508 509} 510 511func (s *RetryLayerBotStore) PermanentDelete(userID string) error { 512 513 tries := 0 514 for { 515 err := s.BotStore.PermanentDelete(userID) 516 if err == nil { 517 return nil 518 } 519 if !isRepeatableError(err) { 520 return err 521 } 522 tries++ 523 if tries >= 3 { 524 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 525 return err 526 } 527 } 528 529} 530 531func (s *RetryLayerBotStore) Save(bot *model.Bot) (*model.Bot, error) { 532 533 tries := 0 534 for { 535 result, err := s.BotStore.Save(bot) 536 if err == nil { 537 return result, nil 538 } 539 if !isRepeatableError(err) { 540 return result, err 541 } 542 tries++ 543 if tries >= 3 { 544 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 545 return result, err 546 } 547 } 548 549} 550 551func (s *RetryLayerBotStore) Update(bot *model.Bot) (*model.Bot, error) { 552 553 tries := 0 554 for { 555 result, err := s.BotStore.Update(bot) 556 if err == nil { 557 return result, nil 558 } 559 if !isRepeatableError(err) { 560 return result, err 561 } 562 tries++ 563 if tries >= 3 { 564 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 565 return result, err 566 } 567 } 568 569} 570 571func (s *RetryLayerChannelStore) AnalyticsDeletedTypeCount(teamID string, channelType string) (int64, error) { 572 573 tries := 0 574 for { 575 result, err := s.ChannelStore.AnalyticsDeletedTypeCount(teamID, channelType) 576 if err == nil { 577 return result, nil 578 } 579 if !isRepeatableError(err) { 580 return result, err 581 } 582 tries++ 583 if tries >= 3 { 584 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 585 return result, err 586 } 587 } 588 589} 590 591func (s *RetryLayerChannelStore) AnalyticsTypeCount(teamID string, channelType model.ChannelType) (int64, error) { 592 593 tries := 0 594 for { 595 result, err := s.ChannelStore.AnalyticsTypeCount(teamID, channelType) 596 if err == nil { 597 return result, nil 598 } 599 if !isRepeatableError(err) { 600 return result, err 601 } 602 tries++ 603 if tries >= 3 { 604 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 605 return result, err 606 } 607 } 608 609} 610 611func (s *RetryLayerChannelStore) AutocompleteInTeam(teamID string, term string, includeDeleted bool) (model.ChannelList, error) { 612 613 tries := 0 614 for { 615 result, err := s.ChannelStore.AutocompleteInTeam(teamID, term, includeDeleted) 616 if err == nil { 617 return result, nil 618 } 619 if !isRepeatableError(err) { 620 return result, err 621 } 622 tries++ 623 if tries >= 3 { 624 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 625 return result, err 626 } 627 } 628 629} 630 631func (s *RetryLayerChannelStore) AutocompleteInTeamForSearch(teamID string, userID string, term string, includeDeleted bool) (model.ChannelList, error) { 632 633 tries := 0 634 for { 635 result, err := s.ChannelStore.AutocompleteInTeamForSearch(teamID, userID, term, includeDeleted) 636 if err == nil { 637 return result, nil 638 } 639 if !isRepeatableError(err) { 640 return result, err 641 } 642 tries++ 643 if tries >= 3 { 644 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 645 return result, err 646 } 647 } 648 649} 650 651func (s *RetryLayerChannelStore) ClearAllCustomRoleAssignments() error { 652 653 tries := 0 654 for { 655 err := s.ChannelStore.ClearAllCustomRoleAssignments() 656 if err == nil { 657 return nil 658 } 659 if !isRepeatableError(err) { 660 return err 661 } 662 tries++ 663 if tries >= 3 { 664 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 665 return err 666 } 667 } 668 669} 670 671func (s *RetryLayerChannelStore) ClearCaches() { 672 673 s.ChannelStore.ClearCaches() 674 675} 676 677func (s *RetryLayerChannelStore) ClearSidebarOnTeamLeave(userID string, teamID string) error { 678 679 tries := 0 680 for { 681 err := s.ChannelStore.ClearSidebarOnTeamLeave(userID, teamID) 682 if err == nil { 683 return nil 684 } 685 if !isRepeatableError(err) { 686 return err 687 } 688 tries++ 689 if tries >= 3 { 690 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 691 return err 692 } 693 } 694 695} 696 697func (s *RetryLayerChannelStore) CountPostsAfter(channelID string, timestamp int64, userID string) (int, int, error) { 698 699 tries := 0 700 for { 701 result, resultVar1, err := s.ChannelStore.CountPostsAfter(channelID, timestamp, userID) 702 if err == nil { 703 return result, resultVar1, nil 704 } 705 if !isRepeatableError(err) { 706 return result, resultVar1, err 707 } 708 tries++ 709 if tries >= 3 { 710 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 711 return result, resultVar1, err 712 } 713 } 714 715} 716 717func (s *RetryLayerChannelStore) CreateDirectChannel(userID *model.User, otherUserID *model.User, channelOptions ...model.ChannelOption) (*model.Channel, error) { 718 719 tries := 0 720 for { 721 result, err := s.ChannelStore.CreateDirectChannel(userID, otherUserID, channelOptions...) 722 if err == nil { 723 return result, nil 724 } 725 if !isRepeatableError(err) { 726 return result, err 727 } 728 tries++ 729 if tries >= 3 { 730 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 731 return result, err 732 } 733 } 734 735} 736 737func (s *RetryLayerChannelStore) CreateInitialSidebarCategories(userID string, teamID string) (*model.OrderedSidebarCategories, error) { 738 739 tries := 0 740 for { 741 result, err := s.ChannelStore.CreateInitialSidebarCategories(userID, teamID) 742 if err == nil { 743 return result, nil 744 } 745 if !isRepeatableError(err) { 746 return result, err 747 } 748 tries++ 749 if tries >= 3 { 750 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 751 return result, err 752 } 753 } 754 755} 756 757func (s *RetryLayerChannelStore) CreateSidebarCategory(userID string, teamID string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, error) { 758 759 tries := 0 760 for { 761 result, err := s.ChannelStore.CreateSidebarCategory(userID, teamID, newCategory) 762 if err == nil { 763 return result, nil 764 } 765 if !isRepeatableError(err) { 766 return result, err 767 } 768 tries++ 769 if tries >= 3 { 770 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 771 return result, err 772 } 773 } 774 775} 776 777func (s *RetryLayerChannelStore) Delete(channelID string, time int64) error { 778 779 tries := 0 780 for { 781 err := s.ChannelStore.Delete(channelID, time) 782 if err == nil { 783 return nil 784 } 785 if !isRepeatableError(err) { 786 return err 787 } 788 tries++ 789 if tries >= 3 { 790 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 791 return err 792 } 793 } 794 795} 796 797func (s *RetryLayerChannelStore) DeleteSidebarCategory(categoryID string) error { 798 799 tries := 0 800 for { 801 err := s.ChannelStore.DeleteSidebarCategory(categoryID) 802 if err == nil { 803 return nil 804 } 805 if !isRepeatableError(err) { 806 return err 807 } 808 tries++ 809 if tries >= 3 { 810 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 811 return err 812 } 813 } 814 815} 816 817func (s *RetryLayerChannelStore) DeleteSidebarChannelsByPreferences(preferences model.Preferences) error { 818 819 tries := 0 820 for { 821 err := s.ChannelStore.DeleteSidebarChannelsByPreferences(preferences) 822 if err == nil { 823 return nil 824 } 825 if !isRepeatableError(err) { 826 return err 827 } 828 tries++ 829 if tries >= 3 { 830 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 831 return err 832 } 833 } 834 835} 836 837func (s *RetryLayerChannelStore) Get(id string, allowFromCache bool) (*model.Channel, error) { 838 839 tries := 0 840 for { 841 result, err := s.ChannelStore.Get(id, allowFromCache) 842 if err == nil { 843 return result, nil 844 } 845 if !isRepeatableError(err) { 846 return result, err 847 } 848 tries++ 849 if tries >= 3 { 850 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 851 return result, err 852 } 853 } 854 855} 856 857func (s *RetryLayerChannelStore) GetAll(teamID string) ([]*model.Channel, error) { 858 859 tries := 0 860 for { 861 result, err := s.ChannelStore.GetAll(teamID) 862 if err == nil { 863 return result, nil 864 } 865 if !isRepeatableError(err) { 866 return result, err 867 } 868 tries++ 869 if tries >= 3 { 870 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 871 return result, err 872 } 873 } 874 875} 876 877func (s *RetryLayerChannelStore) GetAllChannelMembersForUser(userID string, allowFromCache bool, includeDeleted bool) (map[string]string, error) { 878 879 tries := 0 880 for { 881 result, err := s.ChannelStore.GetAllChannelMembersForUser(userID, allowFromCache, includeDeleted) 882 if err == nil { 883 return result, nil 884 } 885 if !isRepeatableError(err) { 886 return result, err 887 } 888 tries++ 889 if tries >= 3 { 890 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 891 return result, err 892 } 893 } 894 895} 896 897func (s *RetryLayerChannelStore) GetAllChannelMembersNotifyPropsForChannel(channelID string, allowFromCache bool) (map[string]model.StringMap, error) { 898 899 tries := 0 900 for { 901 result, err := s.ChannelStore.GetAllChannelMembersNotifyPropsForChannel(channelID, allowFromCache) 902 if err == nil { 903 return result, nil 904 } 905 if !isRepeatableError(err) { 906 return result, err 907 } 908 tries++ 909 if tries >= 3 { 910 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 911 return result, err 912 } 913 } 914 915} 916 917func (s *RetryLayerChannelStore) GetAllChannels(page int, perPage int, opts store.ChannelSearchOpts) (model.ChannelListWithTeamData, error) { 918 919 tries := 0 920 for { 921 result, err := s.ChannelStore.GetAllChannels(page, perPage, opts) 922 if err == nil { 923 return result, nil 924 } 925 if !isRepeatableError(err) { 926 return result, err 927 } 928 tries++ 929 if tries >= 3 { 930 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 931 return result, err 932 } 933 } 934 935} 936 937func (s *RetryLayerChannelStore) GetAllChannelsCount(opts store.ChannelSearchOpts) (int64, error) { 938 939 tries := 0 940 for { 941 result, err := s.ChannelStore.GetAllChannelsCount(opts) 942 if err == nil { 943 return result, nil 944 } 945 if !isRepeatableError(err) { 946 return result, err 947 } 948 tries++ 949 if tries >= 3 { 950 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 951 return result, err 952 } 953 } 954 955} 956 957func (s *RetryLayerChannelStore) GetAllChannelsForExportAfter(limit int, afterID string) ([]*model.ChannelForExport, error) { 958 959 tries := 0 960 for { 961 result, err := s.ChannelStore.GetAllChannelsForExportAfter(limit, afterID) 962 if err == nil { 963 return result, nil 964 } 965 if !isRepeatableError(err) { 966 return result, err 967 } 968 tries++ 969 if tries >= 3 { 970 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 971 return result, err 972 } 973 } 974 975} 976 977func (s *RetryLayerChannelStore) GetAllDirectChannelsForExportAfter(limit int, afterID string) ([]*model.DirectChannelForExport, error) { 978 979 tries := 0 980 for { 981 result, err := s.ChannelStore.GetAllDirectChannelsForExportAfter(limit, afterID) 982 if err == nil { 983 return result, nil 984 } 985 if !isRepeatableError(err) { 986 return result, err 987 } 988 tries++ 989 if tries >= 3 { 990 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 991 return result, err 992 } 993 } 994 995} 996 997func (s *RetryLayerChannelStore) GetByName(team_id string, name string, allowFromCache bool) (*model.Channel, error) { 998 999 tries := 0 1000 for { 1001 result, err := s.ChannelStore.GetByName(team_id, name, allowFromCache) 1002 if err == nil { 1003 return result, nil 1004 } 1005 if !isRepeatableError(err) { 1006 return result, err 1007 } 1008 tries++ 1009 if tries >= 3 { 1010 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1011 return result, err 1012 } 1013 } 1014 1015} 1016 1017func (s *RetryLayerChannelStore) GetByNameIncludeDeleted(team_id string, name string, allowFromCache bool) (*model.Channel, error) { 1018 1019 tries := 0 1020 for { 1021 result, err := s.ChannelStore.GetByNameIncludeDeleted(team_id, name, allowFromCache) 1022 if err == nil { 1023 return result, nil 1024 } 1025 if !isRepeatableError(err) { 1026 return result, err 1027 } 1028 tries++ 1029 if tries >= 3 { 1030 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1031 return result, err 1032 } 1033 } 1034 1035} 1036 1037func (s *RetryLayerChannelStore) GetByNames(team_id string, names []string, allowFromCache bool) ([]*model.Channel, error) { 1038 1039 tries := 0 1040 for { 1041 result, err := s.ChannelStore.GetByNames(team_id, names, allowFromCache) 1042 if err == nil { 1043 return result, nil 1044 } 1045 if !isRepeatableError(err) { 1046 return result, err 1047 } 1048 tries++ 1049 if tries >= 3 { 1050 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1051 return result, err 1052 } 1053 } 1054 1055} 1056 1057func (s *RetryLayerChannelStore) GetChannelCounts(teamID string, userID string) (*model.ChannelCounts, error) { 1058 1059 tries := 0 1060 for { 1061 result, err := s.ChannelStore.GetChannelCounts(teamID, userID) 1062 if err == nil { 1063 return result, nil 1064 } 1065 if !isRepeatableError(err) { 1066 return result, err 1067 } 1068 tries++ 1069 if tries >= 3 { 1070 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1071 return result, err 1072 } 1073 } 1074 1075} 1076 1077func (s *RetryLayerChannelStore) GetChannelMembersForExport(userID string, teamID string) ([]*model.ChannelMemberForExport, error) { 1078 1079 tries := 0 1080 for { 1081 result, err := s.ChannelStore.GetChannelMembersForExport(userID, teamID) 1082 if err == nil { 1083 return result, nil 1084 } 1085 if !isRepeatableError(err) { 1086 return result, err 1087 } 1088 tries++ 1089 if tries >= 3 { 1090 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1091 return result, err 1092 } 1093 } 1094 1095} 1096 1097func (s *RetryLayerChannelStore) GetChannelMembersTimezones(channelID string) ([]model.StringMap, error) { 1098 1099 tries := 0 1100 for { 1101 result, err := s.ChannelStore.GetChannelMembersTimezones(channelID) 1102 if err == nil { 1103 return result, nil 1104 } 1105 if !isRepeatableError(err) { 1106 return result, err 1107 } 1108 tries++ 1109 if tries >= 3 { 1110 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1111 return result, err 1112 } 1113 } 1114 1115} 1116 1117func (s *RetryLayerChannelStore) GetChannelUnread(channelID string, userID string) (*model.ChannelUnread, error) { 1118 1119 tries := 0 1120 for { 1121 result, err := s.ChannelStore.GetChannelUnread(channelID, userID) 1122 if err == nil { 1123 return result, nil 1124 } 1125 if !isRepeatableError(err) { 1126 return result, err 1127 } 1128 tries++ 1129 if tries >= 3 { 1130 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1131 return result, err 1132 } 1133 } 1134 1135} 1136 1137func (s *RetryLayerChannelStore) GetChannels(teamID string, userID string, includeDeleted bool, lastDeleteAt int) (model.ChannelList, error) { 1138 1139 tries := 0 1140 for { 1141 result, err := s.ChannelStore.GetChannels(teamID, userID, includeDeleted, lastDeleteAt) 1142 if err == nil { 1143 return result, nil 1144 } 1145 if !isRepeatableError(err) { 1146 return result, err 1147 } 1148 tries++ 1149 if tries >= 3 { 1150 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1151 return result, err 1152 } 1153 } 1154 1155} 1156 1157func (s *RetryLayerChannelStore) GetChannelsBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.Channel, error) { 1158 1159 tries := 0 1160 for { 1161 result, err := s.ChannelStore.GetChannelsBatchForIndexing(startTime, endTime, limit) 1162 if err == nil { 1163 return result, nil 1164 } 1165 if !isRepeatableError(err) { 1166 return result, err 1167 } 1168 tries++ 1169 if tries >= 3 { 1170 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1171 return result, err 1172 } 1173 } 1174 1175} 1176 1177func (s *RetryLayerChannelStore) GetChannelsByIds(channelIds []string, includeDeleted bool) ([]*model.Channel, error) { 1178 1179 tries := 0 1180 for { 1181 result, err := s.ChannelStore.GetChannelsByIds(channelIds, includeDeleted) 1182 if err == nil { 1183 return result, nil 1184 } 1185 if !isRepeatableError(err) { 1186 return result, err 1187 } 1188 tries++ 1189 if tries >= 3 { 1190 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1191 return result, err 1192 } 1193 } 1194 1195} 1196 1197func (s *RetryLayerChannelStore) GetChannelsByScheme(schemeID string, offset int, limit int) (model.ChannelList, error) { 1198 1199 tries := 0 1200 for { 1201 result, err := s.ChannelStore.GetChannelsByScheme(schemeID, offset, limit) 1202 if err == nil { 1203 return result, nil 1204 } 1205 if !isRepeatableError(err) { 1206 return result, err 1207 } 1208 tries++ 1209 if tries >= 3 { 1210 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1211 return result, err 1212 } 1213 } 1214 1215} 1216 1217func (s *RetryLayerChannelStore) GetDeleted(team_id string, offset int, limit int, userID string) (model.ChannelList, error) { 1218 1219 tries := 0 1220 for { 1221 result, err := s.ChannelStore.GetDeleted(team_id, offset, limit, userID) 1222 if err == nil { 1223 return result, nil 1224 } 1225 if !isRepeatableError(err) { 1226 return result, err 1227 } 1228 tries++ 1229 if tries >= 3 { 1230 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1231 return result, err 1232 } 1233 } 1234 1235} 1236 1237func (s *RetryLayerChannelStore) GetDeletedByName(team_id string, name string) (*model.Channel, error) { 1238 1239 tries := 0 1240 for { 1241 result, err := s.ChannelStore.GetDeletedByName(team_id, name) 1242 if err == nil { 1243 return result, nil 1244 } 1245 if !isRepeatableError(err) { 1246 return result, err 1247 } 1248 tries++ 1249 if tries >= 3 { 1250 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1251 return result, err 1252 } 1253 } 1254 1255} 1256 1257func (s *RetryLayerChannelStore) GetForPost(postID string) (*model.Channel, error) { 1258 1259 tries := 0 1260 for { 1261 result, err := s.ChannelStore.GetForPost(postID) 1262 if err == nil { 1263 return result, nil 1264 } 1265 if !isRepeatableError(err) { 1266 return result, err 1267 } 1268 tries++ 1269 if tries >= 3 { 1270 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1271 return result, err 1272 } 1273 } 1274 1275} 1276 1277func (s *RetryLayerChannelStore) GetFromMaster(id string) (*model.Channel, error) { 1278 1279 tries := 0 1280 for { 1281 result, err := s.ChannelStore.GetFromMaster(id) 1282 if err == nil { 1283 return result, nil 1284 } 1285 if !isRepeatableError(err) { 1286 return result, err 1287 } 1288 tries++ 1289 if tries >= 3 { 1290 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1291 return result, err 1292 } 1293 } 1294 1295} 1296 1297func (s *RetryLayerChannelStore) GetGuestCount(channelID string, allowFromCache bool) (int64, error) { 1298 1299 tries := 0 1300 for { 1301 result, err := s.ChannelStore.GetGuestCount(channelID, allowFromCache) 1302 if err == nil { 1303 return result, nil 1304 } 1305 if !isRepeatableError(err) { 1306 return result, err 1307 } 1308 tries++ 1309 if tries >= 3 { 1310 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1311 return result, err 1312 } 1313 } 1314 1315} 1316 1317func (s *RetryLayerChannelStore) GetMember(ctx context.Context, channelID string, userID string) (*model.ChannelMember, error) { 1318 1319 tries := 0 1320 for { 1321 result, err := s.ChannelStore.GetMember(ctx, channelID, userID) 1322 if err == nil { 1323 return result, nil 1324 } 1325 if !isRepeatableError(err) { 1326 return result, err 1327 } 1328 tries++ 1329 if tries >= 3 { 1330 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1331 return result, err 1332 } 1333 } 1334 1335} 1336 1337func (s *RetryLayerChannelStore) GetMemberCount(channelID string, allowFromCache bool) (int64, error) { 1338 1339 tries := 0 1340 for { 1341 result, err := s.ChannelStore.GetMemberCount(channelID, allowFromCache) 1342 if err == nil { 1343 return result, nil 1344 } 1345 if !isRepeatableError(err) { 1346 return result, err 1347 } 1348 tries++ 1349 if tries >= 3 { 1350 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1351 return result, err 1352 } 1353 } 1354 1355} 1356 1357func (s *RetryLayerChannelStore) GetMemberCountFromCache(channelID string) int64 { 1358 1359 return s.ChannelStore.GetMemberCountFromCache(channelID) 1360 1361} 1362 1363func (s *RetryLayerChannelStore) GetMemberCountsByGroup(ctx context.Context, channelID string, includeTimezones bool) ([]*model.ChannelMemberCountByGroup, error) { 1364 1365 tries := 0 1366 for { 1367 result, err := s.ChannelStore.GetMemberCountsByGroup(ctx, channelID, includeTimezones) 1368 if err == nil { 1369 return result, nil 1370 } 1371 if !isRepeatableError(err) { 1372 return result, err 1373 } 1374 tries++ 1375 if tries >= 3 { 1376 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1377 return result, err 1378 } 1379 } 1380 1381} 1382 1383func (s *RetryLayerChannelStore) GetMemberForPost(postID string, userID string) (*model.ChannelMember, error) { 1384 1385 tries := 0 1386 for { 1387 result, err := s.ChannelStore.GetMemberForPost(postID, userID) 1388 if err == nil { 1389 return result, nil 1390 } 1391 if !isRepeatableError(err) { 1392 return result, err 1393 } 1394 tries++ 1395 if tries >= 3 { 1396 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1397 return result, err 1398 } 1399 } 1400 1401} 1402 1403func (s *RetryLayerChannelStore) GetMembers(channelID string, offset int, limit int) (model.ChannelMembers, error) { 1404 1405 tries := 0 1406 for { 1407 result, err := s.ChannelStore.GetMembers(channelID, offset, limit) 1408 if err == nil { 1409 return result, nil 1410 } 1411 if !isRepeatableError(err) { 1412 return result, err 1413 } 1414 tries++ 1415 if tries >= 3 { 1416 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1417 return result, err 1418 } 1419 } 1420 1421} 1422 1423func (s *RetryLayerChannelStore) GetMembersByChannelIds(channelIds []string, userID string) (model.ChannelMembers, error) { 1424 1425 tries := 0 1426 for { 1427 result, err := s.ChannelStore.GetMembersByChannelIds(channelIds, userID) 1428 if err == nil { 1429 return result, nil 1430 } 1431 if !isRepeatableError(err) { 1432 return result, err 1433 } 1434 tries++ 1435 if tries >= 3 { 1436 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1437 return result, err 1438 } 1439 } 1440 1441} 1442 1443func (s *RetryLayerChannelStore) GetMembersByIds(channelID string, userIds []string) (model.ChannelMembers, error) { 1444 1445 tries := 0 1446 for { 1447 result, err := s.ChannelStore.GetMembersByIds(channelID, userIds) 1448 if err == nil { 1449 return result, nil 1450 } 1451 if !isRepeatableError(err) { 1452 return result, err 1453 } 1454 tries++ 1455 if tries >= 3 { 1456 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1457 return result, err 1458 } 1459 } 1460 1461} 1462 1463func (s *RetryLayerChannelStore) GetMembersForUser(teamID string, userID string) (model.ChannelMembers, error) { 1464 1465 tries := 0 1466 for { 1467 result, err := s.ChannelStore.GetMembersForUser(teamID, userID) 1468 if err == nil { 1469 return result, nil 1470 } 1471 if !isRepeatableError(err) { 1472 return result, err 1473 } 1474 tries++ 1475 if tries >= 3 { 1476 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1477 return result, err 1478 } 1479 } 1480 1481} 1482 1483func (s *RetryLayerChannelStore) GetMembersForUserWithPagination(teamID string, userID string, page int, perPage int) (model.ChannelMembers, error) { 1484 1485 tries := 0 1486 for { 1487 result, err := s.ChannelStore.GetMembersForUserWithPagination(teamID, userID, page, perPage) 1488 if err == nil { 1489 return result, nil 1490 } 1491 if !isRepeatableError(err) { 1492 return result, err 1493 } 1494 tries++ 1495 if tries >= 3 { 1496 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1497 return result, err 1498 } 1499 } 1500 1501} 1502 1503func (s *RetryLayerChannelStore) GetMoreChannels(teamID string, userID string, offset int, limit int) (model.ChannelList, error) { 1504 1505 tries := 0 1506 for { 1507 result, err := s.ChannelStore.GetMoreChannels(teamID, userID, offset, limit) 1508 if err == nil { 1509 return result, nil 1510 } 1511 if !isRepeatableError(err) { 1512 return result, err 1513 } 1514 tries++ 1515 if tries >= 3 { 1516 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1517 return result, err 1518 } 1519 } 1520 1521} 1522 1523func (s *RetryLayerChannelStore) GetPinnedPostCount(channelID string, allowFromCache bool) (int64, error) { 1524 1525 tries := 0 1526 for { 1527 result, err := s.ChannelStore.GetPinnedPostCount(channelID, allowFromCache) 1528 if err == nil { 1529 return result, nil 1530 } 1531 if !isRepeatableError(err) { 1532 return result, err 1533 } 1534 tries++ 1535 if tries >= 3 { 1536 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1537 return result, err 1538 } 1539 } 1540 1541} 1542 1543func (s *RetryLayerChannelStore) GetPinnedPosts(channelID string) (*model.PostList, error) { 1544 1545 tries := 0 1546 for { 1547 result, err := s.ChannelStore.GetPinnedPosts(channelID) 1548 if err == nil { 1549 return result, nil 1550 } 1551 if !isRepeatableError(err) { 1552 return result, err 1553 } 1554 tries++ 1555 if tries >= 3 { 1556 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1557 return result, err 1558 } 1559 } 1560 1561} 1562 1563func (s *RetryLayerChannelStore) GetPrivateChannelsForTeam(teamID string, offset int, limit int) (model.ChannelList, error) { 1564 1565 tries := 0 1566 for { 1567 result, err := s.ChannelStore.GetPrivateChannelsForTeam(teamID, offset, limit) 1568 if err == nil { 1569 return result, nil 1570 } 1571 if !isRepeatableError(err) { 1572 return result, err 1573 } 1574 tries++ 1575 if tries >= 3 { 1576 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1577 return result, err 1578 } 1579 } 1580 1581} 1582 1583func (s *RetryLayerChannelStore) GetPublicChannelsByIdsForTeam(teamID string, channelIds []string) (model.ChannelList, error) { 1584 1585 tries := 0 1586 for { 1587 result, err := s.ChannelStore.GetPublicChannelsByIdsForTeam(teamID, channelIds) 1588 if err == nil { 1589 return result, nil 1590 } 1591 if !isRepeatableError(err) { 1592 return result, err 1593 } 1594 tries++ 1595 if tries >= 3 { 1596 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1597 return result, err 1598 } 1599 } 1600 1601} 1602 1603func (s *RetryLayerChannelStore) GetPublicChannelsForTeam(teamID string, offset int, limit int) (model.ChannelList, error) { 1604 1605 tries := 0 1606 for { 1607 result, err := s.ChannelStore.GetPublicChannelsForTeam(teamID, offset, limit) 1608 if err == nil { 1609 return result, nil 1610 } 1611 if !isRepeatableError(err) { 1612 return result, err 1613 } 1614 tries++ 1615 if tries >= 3 { 1616 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1617 return result, err 1618 } 1619 } 1620 1621} 1622 1623func (s *RetryLayerChannelStore) GetSidebarCategories(userID string, teamID string) (*model.OrderedSidebarCategories, error) { 1624 1625 tries := 0 1626 for { 1627 result, err := s.ChannelStore.GetSidebarCategories(userID, teamID) 1628 if err == nil { 1629 return result, nil 1630 } 1631 if !isRepeatableError(err) { 1632 return result, err 1633 } 1634 tries++ 1635 if tries >= 3 { 1636 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1637 return result, err 1638 } 1639 } 1640 1641} 1642 1643func (s *RetryLayerChannelStore) GetSidebarCategory(categoryID string) (*model.SidebarCategoryWithChannels, error) { 1644 1645 tries := 0 1646 for { 1647 result, err := s.ChannelStore.GetSidebarCategory(categoryID) 1648 if err == nil { 1649 return result, nil 1650 } 1651 if !isRepeatableError(err) { 1652 return result, err 1653 } 1654 tries++ 1655 if tries >= 3 { 1656 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1657 return result, err 1658 } 1659 } 1660 1661} 1662 1663func (s *RetryLayerChannelStore) GetSidebarCategoryOrder(userID string, teamID string) ([]string, error) { 1664 1665 tries := 0 1666 for { 1667 result, err := s.ChannelStore.GetSidebarCategoryOrder(userID, teamID) 1668 if err == nil { 1669 return result, nil 1670 } 1671 if !isRepeatableError(err) { 1672 return result, err 1673 } 1674 tries++ 1675 if tries >= 3 { 1676 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1677 return result, err 1678 } 1679 } 1680 1681} 1682 1683func (s *RetryLayerChannelStore) GetTeamChannels(teamID string) (model.ChannelList, error) { 1684 1685 tries := 0 1686 for { 1687 result, err := s.ChannelStore.GetTeamChannels(teamID) 1688 if err == nil { 1689 return result, nil 1690 } 1691 if !isRepeatableError(err) { 1692 return result, err 1693 } 1694 tries++ 1695 if tries >= 3 { 1696 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1697 return result, err 1698 } 1699 } 1700 1701} 1702 1703func (s *RetryLayerChannelStore) GetTeamForChannel(channelID string) (*model.Team, error) { 1704 1705 tries := 0 1706 for { 1707 result, err := s.ChannelStore.GetTeamForChannel(channelID) 1708 if err == nil { 1709 return result, nil 1710 } 1711 if !isRepeatableError(err) { 1712 return result, err 1713 } 1714 tries++ 1715 if tries >= 3 { 1716 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1717 return result, err 1718 } 1719 } 1720 1721} 1722 1723func (s *RetryLayerChannelStore) GroupSyncedChannelCount() (int64, error) { 1724 1725 tries := 0 1726 for { 1727 result, err := s.ChannelStore.GroupSyncedChannelCount() 1728 if err == nil { 1729 return result, nil 1730 } 1731 if !isRepeatableError(err) { 1732 return result, err 1733 } 1734 tries++ 1735 if tries >= 3 { 1736 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1737 return result, err 1738 } 1739 } 1740 1741} 1742 1743func (s *RetryLayerChannelStore) IncrementMentionCount(channelID string, userID string, updateThreads bool, isRoot bool) error { 1744 1745 tries := 0 1746 for { 1747 err := s.ChannelStore.IncrementMentionCount(channelID, userID, updateThreads, isRoot) 1748 if err == nil { 1749 return nil 1750 } 1751 if !isRepeatableError(err) { 1752 return err 1753 } 1754 tries++ 1755 if tries >= 3 { 1756 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1757 return err 1758 } 1759 } 1760 1761} 1762 1763func (s *RetryLayerChannelStore) InvalidateAllChannelMembersForUser(userID string) { 1764 1765 s.ChannelStore.InvalidateAllChannelMembersForUser(userID) 1766 1767} 1768 1769func (s *RetryLayerChannelStore) InvalidateCacheForChannelMembersNotifyProps(channelID string) { 1770 1771 s.ChannelStore.InvalidateCacheForChannelMembersNotifyProps(channelID) 1772 1773} 1774 1775func (s *RetryLayerChannelStore) InvalidateChannel(id string) { 1776 1777 s.ChannelStore.InvalidateChannel(id) 1778 1779} 1780 1781func (s *RetryLayerChannelStore) InvalidateChannelByName(teamID string, name string) { 1782 1783 s.ChannelStore.InvalidateChannelByName(teamID, name) 1784 1785} 1786 1787func (s *RetryLayerChannelStore) InvalidateGuestCount(channelID string) { 1788 1789 s.ChannelStore.InvalidateGuestCount(channelID) 1790 1791} 1792 1793func (s *RetryLayerChannelStore) InvalidateMemberCount(channelID string) { 1794 1795 s.ChannelStore.InvalidateMemberCount(channelID) 1796 1797} 1798 1799func (s *RetryLayerChannelStore) InvalidatePinnedPostCount(channelID string) { 1800 1801 s.ChannelStore.InvalidatePinnedPostCount(channelID) 1802 1803} 1804 1805func (s *RetryLayerChannelStore) IsUserInChannelUseCache(userID string, channelID string) bool { 1806 1807 return s.ChannelStore.IsUserInChannelUseCache(userID, channelID) 1808 1809} 1810 1811func (s *RetryLayerChannelStore) MigrateChannelMembers(fromChannelID string, fromUserID string) (map[string]string, error) { 1812 1813 tries := 0 1814 for { 1815 result, err := s.ChannelStore.MigrateChannelMembers(fromChannelID, fromUserID) 1816 if err == nil { 1817 return result, nil 1818 } 1819 if !isRepeatableError(err) { 1820 return result, err 1821 } 1822 tries++ 1823 if tries >= 3 { 1824 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1825 return result, err 1826 } 1827 } 1828 1829} 1830 1831func (s *RetryLayerChannelStore) MigratePublicChannels() error { 1832 1833 tries := 0 1834 for { 1835 err := s.ChannelStore.MigratePublicChannels() 1836 if err == nil { 1837 return nil 1838 } 1839 if !isRepeatableError(err) { 1840 return err 1841 } 1842 tries++ 1843 if tries >= 3 { 1844 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1845 return err 1846 } 1847 } 1848 1849} 1850 1851func (s *RetryLayerChannelStore) PermanentDelete(channelID string) error { 1852 1853 tries := 0 1854 for { 1855 err := s.ChannelStore.PermanentDelete(channelID) 1856 if err == nil { 1857 return nil 1858 } 1859 if !isRepeatableError(err) { 1860 return err 1861 } 1862 tries++ 1863 if tries >= 3 { 1864 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1865 return err 1866 } 1867 } 1868 1869} 1870 1871func (s *RetryLayerChannelStore) PermanentDeleteByTeam(teamID string) error { 1872 1873 tries := 0 1874 for { 1875 err := s.ChannelStore.PermanentDeleteByTeam(teamID) 1876 if err == nil { 1877 return nil 1878 } 1879 if !isRepeatableError(err) { 1880 return err 1881 } 1882 tries++ 1883 if tries >= 3 { 1884 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1885 return err 1886 } 1887 } 1888 1889} 1890 1891func (s *RetryLayerChannelStore) PermanentDeleteMembersByChannel(channelID string) error { 1892 1893 tries := 0 1894 for { 1895 err := s.ChannelStore.PermanentDeleteMembersByChannel(channelID) 1896 if err == nil { 1897 return nil 1898 } 1899 if !isRepeatableError(err) { 1900 return err 1901 } 1902 tries++ 1903 if tries >= 3 { 1904 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1905 return err 1906 } 1907 } 1908 1909} 1910 1911func (s *RetryLayerChannelStore) PermanentDeleteMembersByUser(userID string) error { 1912 1913 tries := 0 1914 for { 1915 err := s.ChannelStore.PermanentDeleteMembersByUser(userID) 1916 if err == nil { 1917 return nil 1918 } 1919 if !isRepeatableError(err) { 1920 return err 1921 } 1922 tries++ 1923 if tries >= 3 { 1924 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1925 return err 1926 } 1927 } 1928 1929} 1930 1931func (s *RetryLayerChannelStore) RemoveAllDeactivatedMembers(channelID string) error { 1932 1933 tries := 0 1934 for { 1935 err := s.ChannelStore.RemoveAllDeactivatedMembers(channelID) 1936 if err == nil { 1937 return nil 1938 } 1939 if !isRepeatableError(err) { 1940 return err 1941 } 1942 tries++ 1943 if tries >= 3 { 1944 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1945 return err 1946 } 1947 } 1948 1949} 1950 1951func (s *RetryLayerChannelStore) RemoveMember(channelID string, userID string) error { 1952 1953 tries := 0 1954 for { 1955 err := s.ChannelStore.RemoveMember(channelID, userID) 1956 if err == nil { 1957 return nil 1958 } 1959 if !isRepeatableError(err) { 1960 return err 1961 } 1962 tries++ 1963 if tries >= 3 { 1964 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1965 return err 1966 } 1967 } 1968 1969} 1970 1971func (s *RetryLayerChannelStore) RemoveMembers(channelID string, userIds []string) error { 1972 1973 tries := 0 1974 for { 1975 err := s.ChannelStore.RemoveMembers(channelID, userIds) 1976 if err == nil { 1977 return nil 1978 } 1979 if !isRepeatableError(err) { 1980 return err 1981 } 1982 tries++ 1983 if tries >= 3 { 1984 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 1985 return err 1986 } 1987 } 1988 1989} 1990 1991func (s *RetryLayerChannelStore) ResetAllChannelSchemes() error { 1992 1993 tries := 0 1994 for { 1995 err := s.ChannelStore.ResetAllChannelSchemes() 1996 if err == nil { 1997 return nil 1998 } 1999 if !isRepeatableError(err) { 2000 return err 2001 } 2002 tries++ 2003 if tries >= 3 { 2004 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2005 return err 2006 } 2007 } 2008 2009} 2010 2011func (s *RetryLayerChannelStore) Restore(channelID string, time int64) error { 2012 2013 tries := 0 2014 for { 2015 err := s.ChannelStore.Restore(channelID, time) 2016 if err == nil { 2017 return nil 2018 } 2019 if !isRepeatableError(err) { 2020 return err 2021 } 2022 tries++ 2023 if tries >= 3 { 2024 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2025 return err 2026 } 2027 } 2028 2029} 2030 2031func (s *RetryLayerChannelStore) Save(channel *model.Channel, maxChannelsPerTeam int64) (*model.Channel, error) { 2032 2033 tries := 0 2034 for { 2035 result, err := s.ChannelStore.Save(channel, maxChannelsPerTeam) 2036 if err == nil { 2037 return result, nil 2038 } 2039 if !isRepeatableError(err) { 2040 return result, err 2041 } 2042 tries++ 2043 if tries >= 3 { 2044 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2045 return result, err 2046 } 2047 } 2048 2049} 2050 2051func (s *RetryLayerChannelStore) SaveDirectChannel(channel *model.Channel, member1 *model.ChannelMember, member2 *model.ChannelMember) (*model.Channel, error) { 2052 2053 tries := 0 2054 for { 2055 result, err := s.ChannelStore.SaveDirectChannel(channel, member1, member2) 2056 if err == nil { 2057 return result, nil 2058 } 2059 if !isRepeatableError(err) { 2060 return result, err 2061 } 2062 tries++ 2063 if tries >= 3 { 2064 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2065 return result, err 2066 } 2067 } 2068 2069} 2070 2071func (s *RetryLayerChannelStore) SaveMember(member *model.ChannelMember) (*model.ChannelMember, error) { 2072 2073 tries := 0 2074 for { 2075 result, err := s.ChannelStore.SaveMember(member) 2076 if err == nil { 2077 return result, nil 2078 } 2079 if !isRepeatableError(err) { 2080 return result, err 2081 } 2082 tries++ 2083 if tries >= 3 { 2084 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2085 return result, err 2086 } 2087 } 2088 2089} 2090 2091func (s *RetryLayerChannelStore) SaveMultipleMembers(members []*model.ChannelMember) ([]*model.ChannelMember, error) { 2092 2093 tries := 0 2094 for { 2095 result, err := s.ChannelStore.SaveMultipleMembers(members) 2096 if err == nil { 2097 return result, nil 2098 } 2099 if !isRepeatableError(err) { 2100 return result, err 2101 } 2102 tries++ 2103 if tries >= 3 { 2104 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2105 return result, err 2106 } 2107 } 2108 2109} 2110 2111func (s *RetryLayerChannelStore) SearchAllChannels(term string, opts store.ChannelSearchOpts) (model.ChannelListWithTeamData, int64, error) { 2112 2113 tries := 0 2114 for { 2115 result, resultVar1, err := s.ChannelStore.SearchAllChannels(term, opts) 2116 if err == nil { 2117 return result, resultVar1, nil 2118 } 2119 if !isRepeatableError(err) { 2120 return result, resultVar1, err 2121 } 2122 tries++ 2123 if tries >= 3 { 2124 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2125 return result, resultVar1, err 2126 } 2127 } 2128 2129} 2130 2131func (s *RetryLayerChannelStore) SearchArchivedInTeam(teamID string, term string, userID string) (model.ChannelList, error) { 2132 2133 tries := 0 2134 for { 2135 result, err := s.ChannelStore.SearchArchivedInTeam(teamID, term, userID) 2136 if err == nil { 2137 return result, nil 2138 } 2139 if !isRepeatableError(err) { 2140 return result, err 2141 } 2142 tries++ 2143 if tries >= 3 { 2144 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2145 return result, err 2146 } 2147 } 2148 2149} 2150 2151func (s *RetryLayerChannelStore) SearchForUserInTeam(userID string, teamID string, term string, includeDeleted bool) (model.ChannelList, error) { 2152 2153 tries := 0 2154 for { 2155 result, err := s.ChannelStore.SearchForUserInTeam(userID, teamID, term, includeDeleted) 2156 if err == nil { 2157 return result, nil 2158 } 2159 if !isRepeatableError(err) { 2160 return result, err 2161 } 2162 tries++ 2163 if tries >= 3 { 2164 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2165 return result, err 2166 } 2167 } 2168 2169} 2170 2171func (s *RetryLayerChannelStore) SearchGroupChannels(userID string, term string) (model.ChannelList, error) { 2172 2173 tries := 0 2174 for { 2175 result, err := s.ChannelStore.SearchGroupChannels(userID, term) 2176 if err == nil { 2177 return result, nil 2178 } 2179 if !isRepeatableError(err) { 2180 return result, err 2181 } 2182 tries++ 2183 if tries >= 3 { 2184 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2185 return result, err 2186 } 2187 } 2188 2189} 2190 2191func (s *RetryLayerChannelStore) SearchInTeam(teamID string, term string, includeDeleted bool) (model.ChannelList, error) { 2192 2193 tries := 0 2194 for { 2195 result, err := s.ChannelStore.SearchInTeam(teamID, term, includeDeleted) 2196 if err == nil { 2197 return result, nil 2198 } 2199 if !isRepeatableError(err) { 2200 return result, err 2201 } 2202 tries++ 2203 if tries >= 3 { 2204 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2205 return result, err 2206 } 2207 } 2208 2209} 2210 2211func (s *RetryLayerChannelStore) SearchMore(userID string, teamID string, term string) (model.ChannelList, error) { 2212 2213 tries := 0 2214 for { 2215 result, err := s.ChannelStore.SearchMore(userID, teamID, term) 2216 if err == nil { 2217 return result, nil 2218 } 2219 if !isRepeatableError(err) { 2220 return result, err 2221 } 2222 tries++ 2223 if tries >= 3 { 2224 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2225 return result, err 2226 } 2227 } 2228 2229} 2230 2231func (s *RetryLayerChannelStore) SetDeleteAt(channelID string, deleteAt int64, updateAt int64) error { 2232 2233 tries := 0 2234 for { 2235 err := s.ChannelStore.SetDeleteAt(channelID, deleteAt, updateAt) 2236 if err == nil { 2237 return nil 2238 } 2239 if !isRepeatableError(err) { 2240 return err 2241 } 2242 tries++ 2243 if tries >= 3 { 2244 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2245 return err 2246 } 2247 } 2248 2249} 2250 2251func (s *RetryLayerChannelStore) SetShared(channelId string, shared bool) error { 2252 2253 tries := 0 2254 for { 2255 err := s.ChannelStore.SetShared(channelId, shared) 2256 if err == nil { 2257 return nil 2258 } 2259 if !isRepeatableError(err) { 2260 return err 2261 } 2262 tries++ 2263 if tries >= 3 { 2264 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2265 return err 2266 } 2267 } 2268 2269} 2270 2271func (s *RetryLayerChannelStore) Update(channel *model.Channel) (*model.Channel, error) { 2272 2273 tries := 0 2274 for { 2275 result, err := s.ChannelStore.Update(channel) 2276 if err == nil { 2277 return result, nil 2278 } 2279 if !isRepeatableError(err) { 2280 return result, err 2281 } 2282 tries++ 2283 if tries >= 3 { 2284 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2285 return result, err 2286 } 2287 } 2288 2289} 2290 2291func (s *RetryLayerChannelStore) UpdateLastViewedAt(channelIds []string, userID string, updateThreads bool) (map[string]int64, error) { 2292 2293 tries := 0 2294 for { 2295 result, err := s.ChannelStore.UpdateLastViewedAt(channelIds, userID, updateThreads) 2296 if err == nil { 2297 return result, nil 2298 } 2299 if !isRepeatableError(err) { 2300 return result, err 2301 } 2302 tries++ 2303 if tries >= 3 { 2304 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2305 return result, err 2306 } 2307 } 2308 2309} 2310 2311func (s *RetryLayerChannelStore) UpdateLastViewedAtPost(unreadPost *model.Post, userID string, mentionCount int, mentionCountRoot int, updateThreads bool, setUnreadCountRoot bool) (*model.ChannelUnreadAt, error) { 2312 2313 tries := 0 2314 for { 2315 result, err := s.ChannelStore.UpdateLastViewedAtPost(unreadPost, userID, mentionCount, mentionCountRoot, updateThreads, setUnreadCountRoot) 2316 if err == nil { 2317 return result, nil 2318 } 2319 if !isRepeatableError(err) { 2320 return result, err 2321 } 2322 tries++ 2323 if tries >= 3 { 2324 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2325 return result, err 2326 } 2327 } 2328 2329} 2330 2331func (s *RetryLayerChannelStore) UpdateMember(member *model.ChannelMember) (*model.ChannelMember, error) { 2332 2333 tries := 0 2334 for { 2335 result, err := s.ChannelStore.UpdateMember(member) 2336 if err == nil { 2337 return result, nil 2338 } 2339 if !isRepeatableError(err) { 2340 return result, err 2341 } 2342 tries++ 2343 if tries >= 3 { 2344 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2345 return result, err 2346 } 2347 } 2348 2349} 2350 2351func (s *RetryLayerChannelStore) UpdateMembersRole(channelID string, userIDs []string) error { 2352 2353 tries := 0 2354 for { 2355 err := s.ChannelStore.UpdateMembersRole(channelID, userIDs) 2356 if err == nil { 2357 return nil 2358 } 2359 if !isRepeatableError(err) { 2360 return err 2361 } 2362 tries++ 2363 if tries >= 3 { 2364 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2365 return err 2366 } 2367 } 2368 2369} 2370 2371func (s *RetryLayerChannelStore) UpdateMultipleMembers(members []*model.ChannelMember) ([]*model.ChannelMember, error) { 2372 2373 tries := 0 2374 for { 2375 result, err := s.ChannelStore.UpdateMultipleMembers(members) 2376 if err == nil { 2377 return result, nil 2378 } 2379 if !isRepeatableError(err) { 2380 return result, err 2381 } 2382 tries++ 2383 if tries >= 3 { 2384 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2385 return result, err 2386 } 2387 } 2388 2389} 2390 2391func (s *RetryLayerChannelStore) UpdateSidebarCategories(userID string, teamID string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, []*model.SidebarCategoryWithChannels, error) { 2392 2393 tries := 0 2394 for { 2395 result, resultVar1, err := s.ChannelStore.UpdateSidebarCategories(userID, teamID, categories) 2396 if err == nil { 2397 return result, resultVar1, nil 2398 } 2399 if !isRepeatableError(err) { 2400 return result, resultVar1, err 2401 } 2402 tries++ 2403 if tries >= 3 { 2404 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2405 return result, resultVar1, err 2406 } 2407 } 2408 2409} 2410 2411func (s *RetryLayerChannelStore) UpdateSidebarCategoryOrder(userID string, teamID string, categoryOrder []string) error { 2412 2413 tries := 0 2414 for { 2415 err := s.ChannelStore.UpdateSidebarCategoryOrder(userID, teamID, categoryOrder) 2416 if err == nil { 2417 return nil 2418 } 2419 if !isRepeatableError(err) { 2420 return err 2421 } 2422 tries++ 2423 if tries >= 3 { 2424 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2425 return err 2426 } 2427 } 2428 2429} 2430 2431func (s *RetryLayerChannelStore) UpdateSidebarChannelCategoryOnMove(channel *model.Channel, newTeamID string) error { 2432 2433 tries := 0 2434 for { 2435 err := s.ChannelStore.UpdateSidebarChannelCategoryOnMove(channel, newTeamID) 2436 if err == nil { 2437 return nil 2438 } 2439 if !isRepeatableError(err) { 2440 return err 2441 } 2442 tries++ 2443 if tries >= 3 { 2444 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2445 return err 2446 } 2447 } 2448 2449} 2450 2451func (s *RetryLayerChannelStore) UpdateSidebarChannelsByPreferences(preferences model.Preferences) error { 2452 2453 tries := 0 2454 for { 2455 err := s.ChannelStore.UpdateSidebarChannelsByPreferences(preferences) 2456 if err == nil { 2457 return nil 2458 } 2459 if !isRepeatableError(err) { 2460 return err 2461 } 2462 tries++ 2463 if tries >= 3 { 2464 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2465 return err 2466 } 2467 } 2468 2469} 2470 2471func (s *RetryLayerChannelStore) UserBelongsToChannels(userID string, channelIds []string) (bool, error) { 2472 2473 tries := 0 2474 for { 2475 result, err := s.ChannelStore.UserBelongsToChannels(userID, channelIds) 2476 if err == nil { 2477 return result, nil 2478 } 2479 if !isRepeatableError(err) { 2480 return result, err 2481 } 2482 tries++ 2483 if tries >= 3 { 2484 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2485 return result, err 2486 } 2487 } 2488 2489} 2490 2491func (s *RetryLayerChannelMemberHistoryStore) DeleteOrphanedRows(limit int) (int64, error) { 2492 2493 tries := 0 2494 for { 2495 result, err := s.ChannelMemberHistoryStore.DeleteOrphanedRows(limit) 2496 if err == nil { 2497 return result, nil 2498 } 2499 if !isRepeatableError(err) { 2500 return result, err 2501 } 2502 tries++ 2503 if tries >= 3 { 2504 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2505 return result, err 2506 } 2507 } 2508 2509} 2510 2511func (s *RetryLayerChannelMemberHistoryStore) GetUsersInChannelDuring(startTime int64, endTime int64, channelID string) ([]*model.ChannelMemberHistoryResult, error) { 2512 2513 tries := 0 2514 for { 2515 result, err := s.ChannelMemberHistoryStore.GetUsersInChannelDuring(startTime, endTime, channelID) 2516 if err == nil { 2517 return result, nil 2518 } 2519 if !isRepeatableError(err) { 2520 return result, err 2521 } 2522 tries++ 2523 if tries >= 3 { 2524 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2525 return result, err 2526 } 2527 } 2528 2529} 2530 2531func (s *RetryLayerChannelMemberHistoryStore) LogJoinEvent(userID string, channelID string, joinTime int64) error { 2532 2533 tries := 0 2534 for { 2535 err := s.ChannelMemberHistoryStore.LogJoinEvent(userID, channelID, joinTime) 2536 if err == nil { 2537 return nil 2538 } 2539 if !isRepeatableError(err) { 2540 return err 2541 } 2542 tries++ 2543 if tries >= 3 { 2544 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2545 return err 2546 } 2547 } 2548 2549} 2550 2551func (s *RetryLayerChannelMemberHistoryStore) LogLeaveEvent(userID string, channelID string, leaveTime int64) error { 2552 2553 tries := 0 2554 for { 2555 err := s.ChannelMemberHistoryStore.LogLeaveEvent(userID, channelID, leaveTime) 2556 if err == nil { 2557 return nil 2558 } 2559 if !isRepeatableError(err) { 2560 return err 2561 } 2562 tries++ 2563 if tries >= 3 { 2564 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2565 return err 2566 } 2567 } 2568 2569} 2570 2571func (s *RetryLayerChannelMemberHistoryStore) PermanentDeleteBatch(endTime int64, limit int64) (int64, error) { 2572 2573 tries := 0 2574 for { 2575 result, err := s.ChannelMemberHistoryStore.PermanentDeleteBatch(endTime, limit) 2576 if err == nil { 2577 return result, nil 2578 } 2579 if !isRepeatableError(err) { 2580 return result, err 2581 } 2582 tries++ 2583 if tries >= 3 { 2584 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2585 return result, err 2586 } 2587 } 2588 2589} 2590 2591func (s *RetryLayerChannelMemberHistoryStore) PermanentDeleteBatchForRetentionPolicies(now int64, globalPolicyEndTime int64, limit int64, cursor model.RetentionPolicyCursor) (int64, model.RetentionPolicyCursor, error) { 2592 2593 tries := 0 2594 for { 2595 result, resultVar1, err := s.ChannelMemberHistoryStore.PermanentDeleteBatchForRetentionPolicies(now, globalPolicyEndTime, limit, cursor) 2596 if err == nil { 2597 return result, resultVar1, nil 2598 } 2599 if !isRepeatableError(err) { 2600 return result, resultVar1, err 2601 } 2602 tries++ 2603 if tries >= 3 { 2604 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2605 return result, resultVar1, err 2606 } 2607 } 2608 2609} 2610 2611func (s *RetryLayerClusterDiscoveryStore) Cleanup() error { 2612 2613 tries := 0 2614 for { 2615 err := s.ClusterDiscoveryStore.Cleanup() 2616 if err == nil { 2617 return nil 2618 } 2619 if !isRepeatableError(err) { 2620 return err 2621 } 2622 tries++ 2623 if tries >= 3 { 2624 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2625 return err 2626 } 2627 } 2628 2629} 2630 2631func (s *RetryLayerClusterDiscoveryStore) Delete(discovery *model.ClusterDiscovery) (bool, error) { 2632 2633 tries := 0 2634 for { 2635 result, err := s.ClusterDiscoveryStore.Delete(discovery) 2636 if err == nil { 2637 return result, nil 2638 } 2639 if !isRepeatableError(err) { 2640 return result, err 2641 } 2642 tries++ 2643 if tries >= 3 { 2644 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2645 return result, err 2646 } 2647 } 2648 2649} 2650 2651func (s *RetryLayerClusterDiscoveryStore) Exists(discovery *model.ClusterDiscovery) (bool, error) { 2652 2653 tries := 0 2654 for { 2655 result, err := s.ClusterDiscoveryStore.Exists(discovery) 2656 if err == nil { 2657 return result, nil 2658 } 2659 if !isRepeatableError(err) { 2660 return result, err 2661 } 2662 tries++ 2663 if tries >= 3 { 2664 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2665 return result, err 2666 } 2667 } 2668 2669} 2670 2671func (s *RetryLayerClusterDiscoveryStore) GetAll(discoveryType string, clusterName string) ([]*model.ClusterDiscovery, error) { 2672 2673 tries := 0 2674 for { 2675 result, err := s.ClusterDiscoveryStore.GetAll(discoveryType, clusterName) 2676 if err == nil { 2677 return result, nil 2678 } 2679 if !isRepeatableError(err) { 2680 return result, err 2681 } 2682 tries++ 2683 if tries >= 3 { 2684 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2685 return result, err 2686 } 2687 } 2688 2689} 2690 2691func (s *RetryLayerClusterDiscoveryStore) Save(discovery *model.ClusterDiscovery) error { 2692 2693 tries := 0 2694 for { 2695 err := s.ClusterDiscoveryStore.Save(discovery) 2696 if err == nil { 2697 return nil 2698 } 2699 if !isRepeatableError(err) { 2700 return err 2701 } 2702 tries++ 2703 if tries >= 3 { 2704 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2705 return err 2706 } 2707 } 2708 2709} 2710 2711func (s *RetryLayerClusterDiscoveryStore) SetLastPingAt(discovery *model.ClusterDiscovery) error { 2712 2713 tries := 0 2714 for { 2715 err := s.ClusterDiscoveryStore.SetLastPingAt(discovery) 2716 if err == nil { 2717 return nil 2718 } 2719 if !isRepeatableError(err) { 2720 return err 2721 } 2722 tries++ 2723 if tries >= 3 { 2724 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2725 return err 2726 } 2727 } 2728 2729} 2730 2731func (s *RetryLayerCommandStore) AnalyticsCommandCount(teamID string) (int64, error) { 2732 2733 tries := 0 2734 for { 2735 result, err := s.CommandStore.AnalyticsCommandCount(teamID) 2736 if err == nil { 2737 return result, nil 2738 } 2739 if !isRepeatableError(err) { 2740 return result, err 2741 } 2742 tries++ 2743 if tries >= 3 { 2744 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2745 return result, err 2746 } 2747 } 2748 2749} 2750 2751func (s *RetryLayerCommandStore) Delete(commandID string, time int64) error { 2752 2753 tries := 0 2754 for { 2755 err := s.CommandStore.Delete(commandID, time) 2756 if err == nil { 2757 return nil 2758 } 2759 if !isRepeatableError(err) { 2760 return err 2761 } 2762 tries++ 2763 if tries >= 3 { 2764 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2765 return err 2766 } 2767 } 2768 2769} 2770 2771func (s *RetryLayerCommandStore) Get(id string) (*model.Command, error) { 2772 2773 tries := 0 2774 for { 2775 result, err := s.CommandStore.Get(id) 2776 if err == nil { 2777 return result, nil 2778 } 2779 if !isRepeatableError(err) { 2780 return result, err 2781 } 2782 tries++ 2783 if tries >= 3 { 2784 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2785 return result, err 2786 } 2787 } 2788 2789} 2790 2791func (s *RetryLayerCommandStore) GetByTeam(teamID string) ([]*model.Command, error) { 2792 2793 tries := 0 2794 for { 2795 result, err := s.CommandStore.GetByTeam(teamID) 2796 if err == nil { 2797 return result, nil 2798 } 2799 if !isRepeatableError(err) { 2800 return result, err 2801 } 2802 tries++ 2803 if tries >= 3 { 2804 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2805 return result, err 2806 } 2807 } 2808 2809} 2810 2811func (s *RetryLayerCommandStore) GetByTrigger(teamID string, trigger string) (*model.Command, error) { 2812 2813 tries := 0 2814 for { 2815 result, err := s.CommandStore.GetByTrigger(teamID, trigger) 2816 if err == nil { 2817 return result, nil 2818 } 2819 if !isRepeatableError(err) { 2820 return result, err 2821 } 2822 tries++ 2823 if tries >= 3 { 2824 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2825 return result, err 2826 } 2827 } 2828 2829} 2830 2831func (s *RetryLayerCommandStore) PermanentDeleteByTeam(teamID string) error { 2832 2833 tries := 0 2834 for { 2835 err := s.CommandStore.PermanentDeleteByTeam(teamID) 2836 if err == nil { 2837 return nil 2838 } 2839 if !isRepeatableError(err) { 2840 return err 2841 } 2842 tries++ 2843 if tries >= 3 { 2844 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2845 return err 2846 } 2847 } 2848 2849} 2850 2851func (s *RetryLayerCommandStore) PermanentDeleteByUser(userID string) error { 2852 2853 tries := 0 2854 for { 2855 err := s.CommandStore.PermanentDeleteByUser(userID) 2856 if err == nil { 2857 return nil 2858 } 2859 if !isRepeatableError(err) { 2860 return err 2861 } 2862 tries++ 2863 if tries >= 3 { 2864 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2865 return err 2866 } 2867 } 2868 2869} 2870 2871func (s *RetryLayerCommandStore) Save(webhook *model.Command) (*model.Command, error) { 2872 2873 tries := 0 2874 for { 2875 result, err := s.CommandStore.Save(webhook) 2876 if err == nil { 2877 return result, nil 2878 } 2879 if !isRepeatableError(err) { 2880 return result, err 2881 } 2882 tries++ 2883 if tries >= 3 { 2884 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2885 return result, err 2886 } 2887 } 2888 2889} 2890 2891func (s *RetryLayerCommandStore) Update(hook *model.Command) (*model.Command, error) { 2892 2893 tries := 0 2894 for { 2895 result, err := s.CommandStore.Update(hook) 2896 if err == nil { 2897 return result, nil 2898 } 2899 if !isRepeatableError(err) { 2900 return result, err 2901 } 2902 tries++ 2903 if tries >= 3 { 2904 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2905 return result, err 2906 } 2907 } 2908 2909} 2910 2911func (s *RetryLayerCommandWebhookStore) Cleanup() { 2912 2913 s.CommandWebhookStore.Cleanup() 2914 2915} 2916 2917func (s *RetryLayerCommandWebhookStore) Get(id string) (*model.CommandWebhook, error) { 2918 2919 tries := 0 2920 for { 2921 result, err := s.CommandWebhookStore.Get(id) 2922 if err == nil { 2923 return result, nil 2924 } 2925 if !isRepeatableError(err) { 2926 return result, err 2927 } 2928 tries++ 2929 if tries >= 3 { 2930 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2931 return result, err 2932 } 2933 } 2934 2935} 2936 2937func (s *RetryLayerCommandWebhookStore) Save(webhook *model.CommandWebhook) (*model.CommandWebhook, error) { 2938 2939 tries := 0 2940 for { 2941 result, err := s.CommandWebhookStore.Save(webhook) 2942 if err == nil { 2943 return result, nil 2944 } 2945 if !isRepeatableError(err) { 2946 return result, err 2947 } 2948 tries++ 2949 if tries >= 3 { 2950 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2951 return result, err 2952 } 2953 } 2954 2955} 2956 2957func (s *RetryLayerCommandWebhookStore) TryUse(id string, limit int) error { 2958 2959 tries := 0 2960 for { 2961 err := s.CommandWebhookStore.TryUse(id, limit) 2962 if err == nil { 2963 return nil 2964 } 2965 if !isRepeatableError(err) { 2966 return err 2967 } 2968 tries++ 2969 if tries >= 3 { 2970 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2971 return err 2972 } 2973 } 2974 2975} 2976 2977func (s *RetryLayerComplianceStore) ComplianceExport(compliance *model.Compliance, cursor model.ComplianceExportCursor, limit int) ([]*model.CompliancePost, model.ComplianceExportCursor, error) { 2978 2979 tries := 0 2980 for { 2981 result, resultVar1, err := s.ComplianceStore.ComplianceExport(compliance, cursor, limit) 2982 if err == nil { 2983 return result, resultVar1, nil 2984 } 2985 if !isRepeatableError(err) { 2986 return result, resultVar1, err 2987 } 2988 tries++ 2989 if tries >= 3 { 2990 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 2991 return result, resultVar1, err 2992 } 2993 } 2994 2995} 2996 2997func (s *RetryLayerComplianceStore) Get(id string) (*model.Compliance, error) { 2998 2999 tries := 0 3000 for { 3001 result, err := s.ComplianceStore.Get(id) 3002 if err == nil { 3003 return result, nil 3004 } 3005 if !isRepeatableError(err) { 3006 return result, err 3007 } 3008 tries++ 3009 if tries >= 3 { 3010 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3011 return result, err 3012 } 3013 } 3014 3015} 3016 3017func (s *RetryLayerComplianceStore) GetAll(offset int, limit int) (model.Compliances, error) { 3018 3019 tries := 0 3020 for { 3021 result, err := s.ComplianceStore.GetAll(offset, limit) 3022 if err == nil { 3023 return result, nil 3024 } 3025 if !isRepeatableError(err) { 3026 return result, err 3027 } 3028 tries++ 3029 if tries >= 3 { 3030 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3031 return result, err 3032 } 3033 } 3034 3035} 3036 3037func (s *RetryLayerComplianceStore) MessageExport(cursor model.MessageExportCursor, limit int) ([]*model.MessageExport, model.MessageExportCursor, error) { 3038 3039 tries := 0 3040 for { 3041 result, resultVar1, err := s.ComplianceStore.MessageExport(cursor, limit) 3042 if err == nil { 3043 return result, resultVar1, nil 3044 } 3045 if !isRepeatableError(err) { 3046 return result, resultVar1, err 3047 } 3048 tries++ 3049 if tries >= 3 { 3050 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3051 return result, resultVar1, err 3052 } 3053 } 3054 3055} 3056 3057func (s *RetryLayerComplianceStore) Save(compliance *model.Compliance) (*model.Compliance, error) { 3058 3059 tries := 0 3060 for { 3061 result, err := s.ComplianceStore.Save(compliance) 3062 if err == nil { 3063 return result, nil 3064 } 3065 if !isRepeatableError(err) { 3066 return result, err 3067 } 3068 tries++ 3069 if tries >= 3 { 3070 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3071 return result, err 3072 } 3073 } 3074 3075} 3076 3077func (s *RetryLayerComplianceStore) Update(compliance *model.Compliance) (*model.Compliance, error) { 3078 3079 tries := 0 3080 for { 3081 result, err := s.ComplianceStore.Update(compliance) 3082 if err == nil { 3083 return result, nil 3084 } 3085 if !isRepeatableError(err) { 3086 return result, err 3087 } 3088 tries++ 3089 if tries >= 3 { 3090 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3091 return result, err 3092 } 3093 } 3094 3095} 3096 3097func (s *RetryLayerEmojiStore) Delete(emoji *model.Emoji, time int64) error { 3098 3099 tries := 0 3100 for { 3101 err := s.EmojiStore.Delete(emoji, time) 3102 if err == nil { 3103 return nil 3104 } 3105 if !isRepeatableError(err) { 3106 return err 3107 } 3108 tries++ 3109 if tries >= 3 { 3110 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3111 return err 3112 } 3113 } 3114 3115} 3116 3117func (s *RetryLayerEmojiStore) Get(ctx context.Context, id string, allowFromCache bool) (*model.Emoji, error) { 3118 3119 tries := 0 3120 for { 3121 result, err := s.EmojiStore.Get(ctx, id, allowFromCache) 3122 if err == nil { 3123 return result, nil 3124 } 3125 if !isRepeatableError(err) { 3126 return result, err 3127 } 3128 tries++ 3129 if tries >= 3 { 3130 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3131 return result, err 3132 } 3133 } 3134 3135} 3136 3137func (s *RetryLayerEmojiStore) GetByName(ctx context.Context, name string, allowFromCache bool) (*model.Emoji, error) { 3138 3139 tries := 0 3140 for { 3141 result, err := s.EmojiStore.GetByName(ctx, name, allowFromCache) 3142 if err == nil { 3143 return result, nil 3144 } 3145 if !isRepeatableError(err) { 3146 return result, err 3147 } 3148 tries++ 3149 if tries >= 3 { 3150 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3151 return result, err 3152 } 3153 } 3154 3155} 3156 3157func (s *RetryLayerEmojiStore) GetList(offset int, limit int, sort string) ([]*model.Emoji, error) { 3158 3159 tries := 0 3160 for { 3161 result, err := s.EmojiStore.GetList(offset, limit, sort) 3162 if err == nil { 3163 return result, nil 3164 } 3165 if !isRepeatableError(err) { 3166 return result, err 3167 } 3168 tries++ 3169 if tries >= 3 { 3170 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3171 return result, err 3172 } 3173 } 3174 3175} 3176 3177func (s *RetryLayerEmojiStore) GetMultipleByName(names []string) ([]*model.Emoji, error) { 3178 3179 tries := 0 3180 for { 3181 result, err := s.EmojiStore.GetMultipleByName(names) 3182 if err == nil { 3183 return result, nil 3184 } 3185 if !isRepeatableError(err) { 3186 return result, err 3187 } 3188 tries++ 3189 if tries >= 3 { 3190 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3191 return result, err 3192 } 3193 } 3194 3195} 3196 3197func (s *RetryLayerEmojiStore) Save(emoji *model.Emoji) (*model.Emoji, error) { 3198 3199 tries := 0 3200 for { 3201 result, err := s.EmojiStore.Save(emoji) 3202 if err == nil { 3203 return result, nil 3204 } 3205 if !isRepeatableError(err) { 3206 return result, err 3207 } 3208 tries++ 3209 if tries >= 3 { 3210 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3211 return result, err 3212 } 3213 } 3214 3215} 3216 3217func (s *RetryLayerEmojiStore) Search(name string, prefixOnly bool, limit int) ([]*model.Emoji, error) { 3218 3219 tries := 0 3220 for { 3221 result, err := s.EmojiStore.Search(name, prefixOnly, limit) 3222 if err == nil { 3223 return result, nil 3224 } 3225 if !isRepeatableError(err) { 3226 return result, err 3227 } 3228 tries++ 3229 if tries >= 3 { 3230 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3231 return result, err 3232 } 3233 } 3234 3235} 3236 3237func (s *RetryLayerFileInfoStore) AttachToPost(fileID string, postID string, creatorID string) error { 3238 3239 tries := 0 3240 for { 3241 err := s.FileInfoStore.AttachToPost(fileID, postID, creatorID) 3242 if err == nil { 3243 return nil 3244 } 3245 if !isRepeatableError(err) { 3246 return err 3247 } 3248 tries++ 3249 if tries >= 3 { 3250 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3251 return err 3252 } 3253 } 3254 3255} 3256 3257func (s *RetryLayerFileInfoStore) ClearCaches() { 3258 3259 s.FileInfoStore.ClearCaches() 3260 3261} 3262 3263func (s *RetryLayerFileInfoStore) CountAll() (int64, error) { 3264 3265 tries := 0 3266 for { 3267 result, err := s.FileInfoStore.CountAll() 3268 if err == nil { 3269 return result, nil 3270 } 3271 if !isRepeatableError(err) { 3272 return result, err 3273 } 3274 tries++ 3275 if tries >= 3 { 3276 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3277 return result, err 3278 } 3279 } 3280 3281} 3282 3283func (s *RetryLayerFileInfoStore) DeleteForPost(postID string) (string, error) { 3284 3285 tries := 0 3286 for { 3287 result, err := s.FileInfoStore.DeleteForPost(postID) 3288 if err == nil { 3289 return result, nil 3290 } 3291 if !isRepeatableError(err) { 3292 return result, err 3293 } 3294 tries++ 3295 if tries >= 3 { 3296 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3297 return result, err 3298 } 3299 } 3300 3301} 3302 3303func (s *RetryLayerFileInfoStore) Get(id string) (*model.FileInfo, error) { 3304 3305 tries := 0 3306 for { 3307 result, err := s.FileInfoStore.Get(id) 3308 if err == nil { 3309 return result, nil 3310 } 3311 if !isRepeatableError(err) { 3312 return result, err 3313 } 3314 tries++ 3315 if tries >= 3 { 3316 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3317 return result, err 3318 } 3319 } 3320 3321} 3322 3323func (s *RetryLayerFileInfoStore) GetByIds(ids []string) ([]*model.FileInfo, error) { 3324 3325 tries := 0 3326 for { 3327 result, err := s.FileInfoStore.GetByIds(ids) 3328 if err == nil { 3329 return result, nil 3330 } 3331 if !isRepeatableError(err) { 3332 return result, err 3333 } 3334 tries++ 3335 if tries >= 3 { 3336 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3337 return result, err 3338 } 3339 } 3340 3341} 3342 3343func (s *RetryLayerFileInfoStore) GetByPath(path string) (*model.FileInfo, error) { 3344 3345 tries := 0 3346 for { 3347 result, err := s.FileInfoStore.GetByPath(path) 3348 if err == nil { 3349 return result, nil 3350 } 3351 if !isRepeatableError(err) { 3352 return result, err 3353 } 3354 tries++ 3355 if tries >= 3 { 3356 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3357 return result, err 3358 } 3359 } 3360 3361} 3362 3363func (s *RetryLayerFileInfoStore) GetFilesBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.FileForIndexing, error) { 3364 3365 tries := 0 3366 for { 3367 result, err := s.FileInfoStore.GetFilesBatchForIndexing(startTime, endTime, limit) 3368 if err == nil { 3369 return result, nil 3370 } 3371 if !isRepeatableError(err) { 3372 return result, err 3373 } 3374 tries++ 3375 if tries >= 3 { 3376 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3377 return result, err 3378 } 3379 } 3380 3381} 3382 3383func (s *RetryLayerFileInfoStore) GetForPost(postID string, readFromMaster bool, includeDeleted bool, allowFromCache bool) ([]*model.FileInfo, error) { 3384 3385 tries := 0 3386 for { 3387 result, err := s.FileInfoStore.GetForPost(postID, readFromMaster, includeDeleted, allowFromCache) 3388 if err == nil { 3389 return result, nil 3390 } 3391 if !isRepeatableError(err) { 3392 return result, err 3393 } 3394 tries++ 3395 if tries >= 3 { 3396 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3397 return result, err 3398 } 3399 } 3400 3401} 3402 3403func (s *RetryLayerFileInfoStore) GetForUser(userID string) ([]*model.FileInfo, error) { 3404 3405 tries := 0 3406 for { 3407 result, err := s.FileInfoStore.GetForUser(userID) 3408 if err == nil { 3409 return result, nil 3410 } 3411 if !isRepeatableError(err) { 3412 return result, err 3413 } 3414 tries++ 3415 if tries >= 3 { 3416 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3417 return result, err 3418 } 3419 } 3420 3421} 3422 3423func (s *RetryLayerFileInfoStore) GetFromMaster(id string) (*model.FileInfo, error) { 3424 3425 tries := 0 3426 for { 3427 result, err := s.FileInfoStore.GetFromMaster(id) 3428 if err == nil { 3429 return result, nil 3430 } 3431 if !isRepeatableError(err) { 3432 return result, err 3433 } 3434 tries++ 3435 if tries >= 3 { 3436 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3437 return result, err 3438 } 3439 } 3440 3441} 3442 3443func (s *RetryLayerFileInfoStore) GetWithOptions(page int, perPage int, opt *model.GetFileInfosOptions) ([]*model.FileInfo, error) { 3444 3445 tries := 0 3446 for { 3447 result, err := s.FileInfoStore.GetWithOptions(page, perPage, opt) 3448 if err == nil { 3449 return result, nil 3450 } 3451 if !isRepeatableError(err) { 3452 return result, err 3453 } 3454 tries++ 3455 if tries >= 3 { 3456 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3457 return result, err 3458 } 3459 } 3460 3461} 3462 3463func (s *RetryLayerFileInfoStore) InvalidateFileInfosForPostCache(postID string, deleted bool) { 3464 3465 s.FileInfoStore.InvalidateFileInfosForPostCache(postID, deleted) 3466 3467} 3468 3469func (s *RetryLayerFileInfoStore) PermanentDelete(fileID string) error { 3470 3471 tries := 0 3472 for { 3473 err := s.FileInfoStore.PermanentDelete(fileID) 3474 if err == nil { 3475 return nil 3476 } 3477 if !isRepeatableError(err) { 3478 return err 3479 } 3480 tries++ 3481 if tries >= 3 { 3482 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3483 return err 3484 } 3485 } 3486 3487} 3488 3489func (s *RetryLayerFileInfoStore) PermanentDeleteBatch(endTime int64, limit int64) (int64, error) { 3490 3491 tries := 0 3492 for { 3493 result, err := s.FileInfoStore.PermanentDeleteBatch(endTime, limit) 3494 if err == nil { 3495 return result, nil 3496 } 3497 if !isRepeatableError(err) { 3498 return result, err 3499 } 3500 tries++ 3501 if tries >= 3 { 3502 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3503 return result, err 3504 } 3505 } 3506 3507} 3508 3509func (s *RetryLayerFileInfoStore) PermanentDeleteByUser(userID string) (int64, error) { 3510 3511 tries := 0 3512 for { 3513 result, err := s.FileInfoStore.PermanentDeleteByUser(userID) 3514 if err == nil { 3515 return result, nil 3516 } 3517 if !isRepeatableError(err) { 3518 return result, err 3519 } 3520 tries++ 3521 if tries >= 3 { 3522 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3523 return result, err 3524 } 3525 } 3526 3527} 3528 3529func (s *RetryLayerFileInfoStore) Save(info *model.FileInfo) (*model.FileInfo, error) { 3530 3531 tries := 0 3532 for { 3533 result, err := s.FileInfoStore.Save(info) 3534 if err == nil { 3535 return result, nil 3536 } 3537 if !isRepeatableError(err) { 3538 return result, err 3539 } 3540 tries++ 3541 if tries >= 3 { 3542 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3543 return result, err 3544 } 3545 } 3546 3547} 3548 3549func (s *RetryLayerFileInfoStore) Search(paramsList []*model.SearchParams, userID string, teamID string, page int, perPage int) (*model.FileInfoList, error) { 3550 3551 tries := 0 3552 for { 3553 result, err := s.FileInfoStore.Search(paramsList, userID, teamID, page, perPage) 3554 if err == nil { 3555 return result, nil 3556 } 3557 if !isRepeatableError(err) { 3558 return result, err 3559 } 3560 tries++ 3561 if tries >= 3 { 3562 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3563 return result, err 3564 } 3565 } 3566 3567} 3568 3569func (s *RetryLayerFileInfoStore) SetContent(fileID string, content string) error { 3570 3571 tries := 0 3572 for { 3573 err := s.FileInfoStore.SetContent(fileID, content) 3574 if err == nil { 3575 return nil 3576 } 3577 if !isRepeatableError(err) { 3578 return err 3579 } 3580 tries++ 3581 if tries >= 3 { 3582 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3583 return err 3584 } 3585 } 3586 3587} 3588 3589func (s *RetryLayerFileInfoStore) Upsert(info *model.FileInfo) (*model.FileInfo, error) { 3590 3591 tries := 0 3592 for { 3593 result, err := s.FileInfoStore.Upsert(info) 3594 if err == nil { 3595 return result, nil 3596 } 3597 if !isRepeatableError(err) { 3598 return result, err 3599 } 3600 tries++ 3601 if tries >= 3 { 3602 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3603 return result, err 3604 } 3605 } 3606 3607} 3608 3609func (s *RetryLayerGroupStore) AdminRoleGroupsForSyncableMember(userID string, syncableID string, syncableType model.GroupSyncableType) ([]string, error) { 3610 3611 tries := 0 3612 for { 3613 result, err := s.GroupStore.AdminRoleGroupsForSyncableMember(userID, syncableID, syncableType) 3614 if err == nil { 3615 return result, nil 3616 } 3617 if !isRepeatableError(err) { 3618 return result, err 3619 } 3620 tries++ 3621 if tries >= 3 { 3622 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3623 return result, err 3624 } 3625 } 3626 3627} 3628 3629func (s *RetryLayerGroupStore) ChannelMembersMinusGroupMembers(channelID string, groupIDs []string, page int, perPage int) ([]*model.UserWithGroups, error) { 3630 3631 tries := 0 3632 for { 3633 result, err := s.GroupStore.ChannelMembersMinusGroupMembers(channelID, groupIDs, page, perPage) 3634 if err == nil { 3635 return result, nil 3636 } 3637 if !isRepeatableError(err) { 3638 return result, err 3639 } 3640 tries++ 3641 if tries >= 3 { 3642 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3643 return result, err 3644 } 3645 } 3646 3647} 3648 3649func (s *RetryLayerGroupStore) ChannelMembersToAdd(since int64, channelID *string, includeRemovedMembers bool) ([]*model.UserChannelIDPair, error) { 3650 3651 tries := 0 3652 for { 3653 result, err := s.GroupStore.ChannelMembersToAdd(since, channelID, includeRemovedMembers) 3654 if err == nil { 3655 return result, nil 3656 } 3657 if !isRepeatableError(err) { 3658 return result, err 3659 } 3660 tries++ 3661 if tries >= 3 { 3662 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3663 return result, err 3664 } 3665 } 3666 3667} 3668 3669func (s *RetryLayerGroupStore) ChannelMembersToRemove(channelID *string) ([]*model.ChannelMember, error) { 3670 3671 tries := 0 3672 for { 3673 result, err := s.GroupStore.ChannelMembersToRemove(channelID) 3674 if err == nil { 3675 return result, nil 3676 } 3677 if !isRepeatableError(err) { 3678 return result, err 3679 } 3680 tries++ 3681 if tries >= 3 { 3682 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3683 return result, err 3684 } 3685 } 3686 3687} 3688 3689func (s *RetryLayerGroupStore) CountChannelMembersMinusGroupMembers(channelID string, groupIDs []string) (int64, error) { 3690 3691 tries := 0 3692 for { 3693 result, err := s.GroupStore.CountChannelMembersMinusGroupMembers(channelID, groupIDs) 3694 if err == nil { 3695 return result, nil 3696 } 3697 if !isRepeatableError(err) { 3698 return result, err 3699 } 3700 tries++ 3701 if tries >= 3 { 3702 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3703 return result, err 3704 } 3705 } 3706 3707} 3708 3709func (s *RetryLayerGroupStore) CountGroupsByChannel(channelID string, opts model.GroupSearchOpts) (int64, error) { 3710 3711 tries := 0 3712 for { 3713 result, err := s.GroupStore.CountGroupsByChannel(channelID, opts) 3714 if err == nil { 3715 return result, nil 3716 } 3717 if !isRepeatableError(err) { 3718 return result, err 3719 } 3720 tries++ 3721 if tries >= 3 { 3722 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3723 return result, err 3724 } 3725 } 3726 3727} 3728 3729func (s *RetryLayerGroupStore) CountGroupsByTeam(teamID string, opts model.GroupSearchOpts) (int64, error) { 3730 3731 tries := 0 3732 for { 3733 result, err := s.GroupStore.CountGroupsByTeam(teamID, opts) 3734 if err == nil { 3735 return result, nil 3736 } 3737 if !isRepeatableError(err) { 3738 return result, err 3739 } 3740 tries++ 3741 if tries >= 3 { 3742 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3743 return result, err 3744 } 3745 } 3746 3747} 3748 3749func (s *RetryLayerGroupStore) CountTeamMembersMinusGroupMembers(teamID string, groupIDs []string) (int64, error) { 3750 3751 tries := 0 3752 for { 3753 result, err := s.GroupStore.CountTeamMembersMinusGroupMembers(teamID, groupIDs) 3754 if err == nil { 3755 return result, nil 3756 } 3757 if !isRepeatableError(err) { 3758 return result, err 3759 } 3760 tries++ 3761 if tries >= 3 { 3762 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3763 return result, err 3764 } 3765 } 3766 3767} 3768 3769func (s *RetryLayerGroupStore) Create(group *model.Group) (*model.Group, error) { 3770 3771 tries := 0 3772 for { 3773 result, err := s.GroupStore.Create(group) 3774 if err == nil { 3775 return result, nil 3776 } 3777 if !isRepeatableError(err) { 3778 return result, err 3779 } 3780 tries++ 3781 if tries >= 3 { 3782 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3783 return result, err 3784 } 3785 } 3786 3787} 3788 3789func (s *RetryLayerGroupStore) CreateGroupSyncable(groupSyncable *model.GroupSyncable) (*model.GroupSyncable, error) { 3790 3791 tries := 0 3792 for { 3793 result, err := s.GroupStore.CreateGroupSyncable(groupSyncable) 3794 if err == nil { 3795 return result, nil 3796 } 3797 if !isRepeatableError(err) { 3798 return result, err 3799 } 3800 tries++ 3801 if tries >= 3 { 3802 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3803 return result, err 3804 } 3805 } 3806 3807} 3808 3809func (s *RetryLayerGroupStore) Delete(groupID string) (*model.Group, error) { 3810 3811 tries := 0 3812 for { 3813 result, err := s.GroupStore.Delete(groupID) 3814 if err == nil { 3815 return result, nil 3816 } 3817 if !isRepeatableError(err) { 3818 return result, err 3819 } 3820 tries++ 3821 if tries >= 3 { 3822 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3823 return result, err 3824 } 3825 } 3826 3827} 3828 3829func (s *RetryLayerGroupStore) DeleteGroupSyncable(groupID string, syncableID string, syncableType model.GroupSyncableType) (*model.GroupSyncable, error) { 3830 3831 tries := 0 3832 for { 3833 result, err := s.GroupStore.DeleteGroupSyncable(groupID, syncableID, syncableType) 3834 if err == nil { 3835 return result, nil 3836 } 3837 if !isRepeatableError(err) { 3838 return result, err 3839 } 3840 tries++ 3841 if tries >= 3 { 3842 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3843 return result, err 3844 } 3845 } 3846 3847} 3848 3849func (s *RetryLayerGroupStore) DeleteMember(groupID string, userID string) (*model.GroupMember, error) { 3850 3851 tries := 0 3852 for { 3853 result, err := s.GroupStore.DeleteMember(groupID, userID) 3854 if err == nil { 3855 return result, nil 3856 } 3857 if !isRepeatableError(err) { 3858 return result, err 3859 } 3860 tries++ 3861 if tries >= 3 { 3862 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3863 return result, err 3864 } 3865 } 3866 3867} 3868 3869func (s *RetryLayerGroupStore) DistinctGroupMemberCount() (int64, error) { 3870 3871 tries := 0 3872 for { 3873 result, err := s.GroupStore.DistinctGroupMemberCount() 3874 if err == nil { 3875 return result, nil 3876 } 3877 if !isRepeatableError(err) { 3878 return result, err 3879 } 3880 tries++ 3881 if tries >= 3 { 3882 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3883 return result, err 3884 } 3885 } 3886 3887} 3888 3889func (s *RetryLayerGroupStore) Get(groupID string) (*model.Group, error) { 3890 3891 tries := 0 3892 for { 3893 result, err := s.GroupStore.Get(groupID) 3894 if err == nil { 3895 return result, nil 3896 } 3897 if !isRepeatableError(err) { 3898 return result, err 3899 } 3900 tries++ 3901 if tries >= 3 { 3902 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3903 return result, err 3904 } 3905 } 3906 3907} 3908 3909func (s *RetryLayerGroupStore) GetAllBySource(groupSource model.GroupSource) ([]*model.Group, error) { 3910 3911 tries := 0 3912 for { 3913 result, err := s.GroupStore.GetAllBySource(groupSource) 3914 if err == nil { 3915 return result, nil 3916 } 3917 if !isRepeatableError(err) { 3918 return result, err 3919 } 3920 tries++ 3921 if tries >= 3 { 3922 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3923 return result, err 3924 } 3925 } 3926 3927} 3928 3929func (s *RetryLayerGroupStore) GetAllGroupSyncablesByGroupId(groupID string, syncableType model.GroupSyncableType) ([]*model.GroupSyncable, error) { 3930 3931 tries := 0 3932 for { 3933 result, err := s.GroupStore.GetAllGroupSyncablesByGroupId(groupID, syncableType) 3934 if err == nil { 3935 return result, nil 3936 } 3937 if !isRepeatableError(err) { 3938 return result, err 3939 } 3940 tries++ 3941 if tries >= 3 { 3942 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3943 return result, err 3944 } 3945 } 3946 3947} 3948 3949func (s *RetryLayerGroupStore) GetByIDs(groupIDs []string) ([]*model.Group, error) { 3950 3951 tries := 0 3952 for { 3953 result, err := s.GroupStore.GetByIDs(groupIDs) 3954 if err == nil { 3955 return result, nil 3956 } 3957 if !isRepeatableError(err) { 3958 return result, err 3959 } 3960 tries++ 3961 if tries >= 3 { 3962 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3963 return result, err 3964 } 3965 } 3966 3967} 3968 3969func (s *RetryLayerGroupStore) GetByName(name string, opts model.GroupSearchOpts) (*model.Group, error) { 3970 3971 tries := 0 3972 for { 3973 result, err := s.GroupStore.GetByName(name, opts) 3974 if err == nil { 3975 return result, nil 3976 } 3977 if !isRepeatableError(err) { 3978 return result, err 3979 } 3980 tries++ 3981 if tries >= 3 { 3982 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 3983 return result, err 3984 } 3985 } 3986 3987} 3988 3989func (s *RetryLayerGroupStore) GetByRemoteID(remoteID string, groupSource model.GroupSource) (*model.Group, error) { 3990 3991 tries := 0 3992 for { 3993 result, err := s.GroupStore.GetByRemoteID(remoteID, groupSource) 3994 if err == nil { 3995 return result, nil 3996 } 3997 if !isRepeatableError(err) { 3998 return result, err 3999 } 4000 tries++ 4001 if tries >= 3 { 4002 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4003 return result, err 4004 } 4005 } 4006 4007} 4008 4009func (s *RetryLayerGroupStore) GetByUser(userID string) ([]*model.Group, error) { 4010 4011 tries := 0 4012 for { 4013 result, err := s.GroupStore.GetByUser(userID) 4014 if err == nil { 4015 return result, nil 4016 } 4017 if !isRepeatableError(err) { 4018 return result, err 4019 } 4020 tries++ 4021 if tries >= 3 { 4022 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4023 return result, err 4024 } 4025 } 4026 4027} 4028 4029func (s *RetryLayerGroupStore) GetGroupSyncable(groupID string, syncableID string, syncableType model.GroupSyncableType) (*model.GroupSyncable, error) { 4030 4031 tries := 0 4032 for { 4033 result, err := s.GroupStore.GetGroupSyncable(groupID, syncableID, syncableType) 4034 if err == nil { 4035 return result, nil 4036 } 4037 if !isRepeatableError(err) { 4038 return result, err 4039 } 4040 tries++ 4041 if tries >= 3 { 4042 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4043 return result, err 4044 } 4045 } 4046 4047} 4048 4049func (s *RetryLayerGroupStore) GetGroups(page int, perPage int, opts model.GroupSearchOpts) ([]*model.Group, error) { 4050 4051 tries := 0 4052 for { 4053 result, err := s.GroupStore.GetGroups(page, perPage, opts) 4054 if err == nil { 4055 return result, nil 4056 } 4057 if !isRepeatableError(err) { 4058 return result, err 4059 } 4060 tries++ 4061 if tries >= 3 { 4062 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4063 return result, err 4064 } 4065 } 4066 4067} 4068 4069func (s *RetryLayerGroupStore) GetGroupsAssociatedToChannelsByTeam(teamID string, opts model.GroupSearchOpts) (map[string][]*model.GroupWithSchemeAdmin, error) { 4070 4071 tries := 0 4072 for { 4073 result, err := s.GroupStore.GetGroupsAssociatedToChannelsByTeam(teamID, opts) 4074 if err == nil { 4075 return result, nil 4076 } 4077 if !isRepeatableError(err) { 4078 return result, err 4079 } 4080 tries++ 4081 if tries >= 3 { 4082 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4083 return result, err 4084 } 4085 } 4086 4087} 4088 4089func (s *RetryLayerGroupStore) GetGroupsByChannel(channelID string, opts model.GroupSearchOpts) ([]*model.GroupWithSchemeAdmin, error) { 4090 4091 tries := 0 4092 for { 4093 result, err := s.GroupStore.GetGroupsByChannel(channelID, opts) 4094 if err == nil { 4095 return result, nil 4096 } 4097 if !isRepeatableError(err) { 4098 return result, err 4099 } 4100 tries++ 4101 if tries >= 3 { 4102 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4103 return result, err 4104 } 4105 } 4106 4107} 4108 4109func (s *RetryLayerGroupStore) GetGroupsByTeam(teamID string, opts model.GroupSearchOpts) ([]*model.GroupWithSchemeAdmin, error) { 4110 4111 tries := 0 4112 for { 4113 result, err := s.GroupStore.GetGroupsByTeam(teamID, opts) 4114 if err == nil { 4115 return result, nil 4116 } 4117 if !isRepeatableError(err) { 4118 return result, err 4119 } 4120 tries++ 4121 if tries >= 3 { 4122 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4123 return result, err 4124 } 4125 } 4126 4127} 4128 4129func (s *RetryLayerGroupStore) GetMemberCount(groupID string) (int64, error) { 4130 4131 tries := 0 4132 for { 4133 result, err := s.GroupStore.GetMemberCount(groupID) 4134 if err == nil { 4135 return result, nil 4136 } 4137 if !isRepeatableError(err) { 4138 return result, err 4139 } 4140 tries++ 4141 if tries >= 3 { 4142 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4143 return result, err 4144 } 4145 } 4146 4147} 4148 4149func (s *RetryLayerGroupStore) GetMemberUsers(groupID string) ([]*model.User, error) { 4150 4151 tries := 0 4152 for { 4153 result, err := s.GroupStore.GetMemberUsers(groupID) 4154 if err == nil { 4155 return result, nil 4156 } 4157 if !isRepeatableError(err) { 4158 return result, err 4159 } 4160 tries++ 4161 if tries >= 3 { 4162 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4163 return result, err 4164 } 4165 } 4166 4167} 4168 4169func (s *RetryLayerGroupStore) GetMemberUsersInTeam(groupID string, teamID string) ([]*model.User, error) { 4170 4171 tries := 0 4172 for { 4173 result, err := s.GroupStore.GetMemberUsersInTeam(groupID, teamID) 4174 if err == nil { 4175 return result, nil 4176 } 4177 if !isRepeatableError(err) { 4178 return result, err 4179 } 4180 tries++ 4181 if tries >= 3 { 4182 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4183 return result, err 4184 } 4185 } 4186 4187} 4188 4189func (s *RetryLayerGroupStore) GetMemberUsersNotInChannel(groupID string, channelID string) ([]*model.User, error) { 4190 4191 tries := 0 4192 for { 4193 result, err := s.GroupStore.GetMemberUsersNotInChannel(groupID, channelID) 4194 if err == nil { 4195 return result, nil 4196 } 4197 if !isRepeatableError(err) { 4198 return result, err 4199 } 4200 tries++ 4201 if tries >= 3 { 4202 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4203 return result, err 4204 } 4205 } 4206 4207} 4208 4209func (s *RetryLayerGroupStore) GetMemberUsersPage(groupID string, page int, perPage int) ([]*model.User, error) { 4210 4211 tries := 0 4212 for { 4213 result, err := s.GroupStore.GetMemberUsersPage(groupID, page, perPage) 4214 if err == nil { 4215 return result, nil 4216 } 4217 if !isRepeatableError(err) { 4218 return result, err 4219 } 4220 tries++ 4221 if tries >= 3 { 4222 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4223 return result, err 4224 } 4225 } 4226 4227} 4228 4229func (s *RetryLayerGroupStore) GroupChannelCount() (int64, error) { 4230 4231 tries := 0 4232 for { 4233 result, err := s.GroupStore.GroupChannelCount() 4234 if err == nil { 4235 return result, nil 4236 } 4237 if !isRepeatableError(err) { 4238 return result, err 4239 } 4240 tries++ 4241 if tries >= 3 { 4242 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4243 return result, err 4244 } 4245 } 4246 4247} 4248 4249func (s *RetryLayerGroupStore) GroupCount() (int64, error) { 4250 4251 tries := 0 4252 for { 4253 result, err := s.GroupStore.GroupCount() 4254 if err == nil { 4255 return result, nil 4256 } 4257 if !isRepeatableError(err) { 4258 return result, err 4259 } 4260 tries++ 4261 if tries >= 3 { 4262 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4263 return result, err 4264 } 4265 } 4266 4267} 4268 4269func (s *RetryLayerGroupStore) GroupCountWithAllowReference() (int64, error) { 4270 4271 tries := 0 4272 for { 4273 result, err := s.GroupStore.GroupCountWithAllowReference() 4274 if err == nil { 4275 return result, nil 4276 } 4277 if !isRepeatableError(err) { 4278 return result, err 4279 } 4280 tries++ 4281 if tries >= 3 { 4282 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4283 return result, err 4284 } 4285 } 4286 4287} 4288 4289func (s *RetryLayerGroupStore) GroupMemberCount() (int64, error) { 4290 4291 tries := 0 4292 for { 4293 result, err := s.GroupStore.GroupMemberCount() 4294 if err == nil { 4295 return result, nil 4296 } 4297 if !isRepeatableError(err) { 4298 return result, err 4299 } 4300 tries++ 4301 if tries >= 3 { 4302 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4303 return result, err 4304 } 4305 } 4306 4307} 4308 4309func (s *RetryLayerGroupStore) GroupTeamCount() (int64, error) { 4310 4311 tries := 0 4312 for { 4313 result, err := s.GroupStore.GroupTeamCount() 4314 if err == nil { 4315 return result, nil 4316 } 4317 if !isRepeatableError(err) { 4318 return result, err 4319 } 4320 tries++ 4321 if tries >= 3 { 4322 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4323 return result, err 4324 } 4325 } 4326 4327} 4328 4329func (s *RetryLayerGroupStore) PermanentDeleteMembersByUser(userID string) error { 4330 4331 tries := 0 4332 for { 4333 err := s.GroupStore.PermanentDeleteMembersByUser(userID) 4334 if err == nil { 4335 return nil 4336 } 4337 if !isRepeatableError(err) { 4338 return err 4339 } 4340 tries++ 4341 if tries >= 3 { 4342 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4343 return err 4344 } 4345 } 4346 4347} 4348 4349func (s *RetryLayerGroupStore) PermittedSyncableAdmins(syncableID string, syncableType model.GroupSyncableType) ([]string, error) { 4350 4351 tries := 0 4352 for { 4353 result, err := s.GroupStore.PermittedSyncableAdmins(syncableID, syncableType) 4354 if err == nil { 4355 return result, nil 4356 } 4357 if !isRepeatableError(err) { 4358 return result, err 4359 } 4360 tries++ 4361 if tries >= 3 { 4362 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4363 return result, err 4364 } 4365 } 4366 4367} 4368 4369func (s *RetryLayerGroupStore) TeamMembersMinusGroupMembers(teamID string, groupIDs []string, page int, perPage int) ([]*model.UserWithGroups, error) { 4370 4371 tries := 0 4372 for { 4373 result, err := s.GroupStore.TeamMembersMinusGroupMembers(teamID, groupIDs, page, perPage) 4374 if err == nil { 4375 return result, nil 4376 } 4377 if !isRepeatableError(err) { 4378 return result, err 4379 } 4380 tries++ 4381 if tries >= 3 { 4382 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4383 return result, err 4384 } 4385 } 4386 4387} 4388 4389func (s *RetryLayerGroupStore) TeamMembersToAdd(since int64, teamID *string, includeRemovedMembers bool) ([]*model.UserTeamIDPair, error) { 4390 4391 tries := 0 4392 for { 4393 result, err := s.GroupStore.TeamMembersToAdd(since, teamID, includeRemovedMembers) 4394 if err == nil { 4395 return result, nil 4396 } 4397 if !isRepeatableError(err) { 4398 return result, err 4399 } 4400 tries++ 4401 if tries >= 3 { 4402 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4403 return result, err 4404 } 4405 } 4406 4407} 4408 4409func (s *RetryLayerGroupStore) TeamMembersToRemove(teamID *string) ([]*model.TeamMember, error) { 4410 4411 tries := 0 4412 for { 4413 result, err := s.GroupStore.TeamMembersToRemove(teamID) 4414 if err == nil { 4415 return result, nil 4416 } 4417 if !isRepeatableError(err) { 4418 return result, err 4419 } 4420 tries++ 4421 if tries >= 3 { 4422 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4423 return result, err 4424 } 4425 } 4426 4427} 4428 4429func (s *RetryLayerGroupStore) Update(group *model.Group) (*model.Group, error) { 4430 4431 tries := 0 4432 for { 4433 result, err := s.GroupStore.Update(group) 4434 if err == nil { 4435 return result, nil 4436 } 4437 if !isRepeatableError(err) { 4438 return result, err 4439 } 4440 tries++ 4441 if tries >= 3 { 4442 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4443 return result, err 4444 } 4445 } 4446 4447} 4448 4449func (s *RetryLayerGroupStore) UpdateGroupSyncable(groupSyncable *model.GroupSyncable) (*model.GroupSyncable, error) { 4450 4451 tries := 0 4452 for { 4453 result, err := s.GroupStore.UpdateGroupSyncable(groupSyncable) 4454 if err == nil { 4455 return result, nil 4456 } 4457 if !isRepeatableError(err) { 4458 return result, err 4459 } 4460 tries++ 4461 if tries >= 3 { 4462 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4463 return result, err 4464 } 4465 } 4466 4467} 4468 4469func (s *RetryLayerGroupStore) UpsertMember(groupID string, userID string) (*model.GroupMember, error) { 4470 4471 tries := 0 4472 for { 4473 result, err := s.GroupStore.UpsertMember(groupID, userID) 4474 if err == nil { 4475 return result, nil 4476 } 4477 if !isRepeatableError(err) { 4478 return result, err 4479 } 4480 tries++ 4481 if tries >= 3 { 4482 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4483 return result, err 4484 } 4485 } 4486 4487} 4488 4489func (s *RetryLayerJobStore) Delete(id string) (string, error) { 4490 4491 tries := 0 4492 for { 4493 result, err := s.JobStore.Delete(id) 4494 if err == nil { 4495 return result, nil 4496 } 4497 if !isRepeatableError(err) { 4498 return result, err 4499 } 4500 tries++ 4501 if tries >= 3 { 4502 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4503 return result, err 4504 } 4505 } 4506 4507} 4508 4509func (s *RetryLayerJobStore) Get(id string) (*model.Job, error) { 4510 4511 tries := 0 4512 for { 4513 result, err := s.JobStore.Get(id) 4514 if err == nil { 4515 return result, nil 4516 } 4517 if !isRepeatableError(err) { 4518 return result, err 4519 } 4520 tries++ 4521 if tries >= 3 { 4522 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4523 return result, err 4524 } 4525 } 4526 4527} 4528 4529func (s *RetryLayerJobStore) GetAllByStatus(status string) ([]*model.Job, error) { 4530 4531 tries := 0 4532 for { 4533 result, err := s.JobStore.GetAllByStatus(status) 4534 if err == nil { 4535 return result, nil 4536 } 4537 if !isRepeatableError(err) { 4538 return result, err 4539 } 4540 tries++ 4541 if tries >= 3 { 4542 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4543 return result, err 4544 } 4545 } 4546 4547} 4548 4549func (s *RetryLayerJobStore) GetAllByType(jobType string) ([]*model.Job, error) { 4550 4551 tries := 0 4552 for { 4553 result, err := s.JobStore.GetAllByType(jobType) 4554 if err == nil { 4555 return result, nil 4556 } 4557 if !isRepeatableError(err) { 4558 return result, err 4559 } 4560 tries++ 4561 if tries >= 3 { 4562 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4563 return result, err 4564 } 4565 } 4566 4567} 4568 4569func (s *RetryLayerJobStore) GetAllByTypePage(jobType string, offset int, limit int) ([]*model.Job, error) { 4570 4571 tries := 0 4572 for { 4573 result, err := s.JobStore.GetAllByTypePage(jobType, offset, limit) 4574 if err == nil { 4575 return result, nil 4576 } 4577 if !isRepeatableError(err) { 4578 return result, err 4579 } 4580 tries++ 4581 if tries >= 3 { 4582 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4583 return result, err 4584 } 4585 } 4586 4587} 4588 4589func (s *RetryLayerJobStore) GetAllByTypesPage(jobTypes []string, offset int, limit int) ([]*model.Job, error) { 4590 4591 tries := 0 4592 for { 4593 result, err := s.JobStore.GetAllByTypesPage(jobTypes, offset, limit) 4594 if err == nil { 4595 return result, nil 4596 } 4597 if !isRepeatableError(err) { 4598 return result, err 4599 } 4600 tries++ 4601 if tries >= 3 { 4602 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4603 return result, err 4604 } 4605 } 4606 4607} 4608 4609func (s *RetryLayerJobStore) GetAllPage(offset int, limit int) ([]*model.Job, error) { 4610 4611 tries := 0 4612 for { 4613 result, err := s.JobStore.GetAllPage(offset, limit) 4614 if err == nil { 4615 return result, nil 4616 } 4617 if !isRepeatableError(err) { 4618 return result, err 4619 } 4620 tries++ 4621 if tries >= 3 { 4622 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4623 return result, err 4624 } 4625 } 4626 4627} 4628 4629func (s *RetryLayerJobStore) GetCountByStatusAndType(status string, jobType string) (int64, error) { 4630 4631 tries := 0 4632 for { 4633 result, err := s.JobStore.GetCountByStatusAndType(status, jobType) 4634 if err == nil { 4635 return result, nil 4636 } 4637 if !isRepeatableError(err) { 4638 return result, err 4639 } 4640 tries++ 4641 if tries >= 3 { 4642 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4643 return result, err 4644 } 4645 } 4646 4647} 4648 4649func (s *RetryLayerJobStore) GetNewestJobByStatusAndType(status string, jobType string) (*model.Job, error) { 4650 4651 tries := 0 4652 for { 4653 result, err := s.JobStore.GetNewestJobByStatusAndType(status, jobType) 4654 if err == nil { 4655 return result, nil 4656 } 4657 if !isRepeatableError(err) { 4658 return result, err 4659 } 4660 tries++ 4661 if tries >= 3 { 4662 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4663 return result, err 4664 } 4665 } 4666 4667} 4668 4669func (s *RetryLayerJobStore) GetNewestJobByStatusesAndType(statuses []string, jobType string) (*model.Job, error) { 4670 4671 tries := 0 4672 for { 4673 result, err := s.JobStore.GetNewestJobByStatusesAndType(statuses, jobType) 4674 if err == nil { 4675 return result, nil 4676 } 4677 if !isRepeatableError(err) { 4678 return result, err 4679 } 4680 tries++ 4681 if tries >= 3 { 4682 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4683 return result, err 4684 } 4685 } 4686 4687} 4688 4689func (s *RetryLayerJobStore) Save(job *model.Job) (*model.Job, error) { 4690 4691 tries := 0 4692 for { 4693 result, err := s.JobStore.Save(job) 4694 if err == nil { 4695 return result, nil 4696 } 4697 if !isRepeatableError(err) { 4698 return result, err 4699 } 4700 tries++ 4701 if tries >= 3 { 4702 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4703 return result, err 4704 } 4705 } 4706 4707} 4708 4709func (s *RetryLayerJobStore) UpdateOptimistically(job *model.Job, currentStatus string) (bool, error) { 4710 4711 tries := 0 4712 for { 4713 result, err := s.JobStore.UpdateOptimistically(job, currentStatus) 4714 if err == nil { 4715 return result, nil 4716 } 4717 if !isRepeatableError(err) { 4718 return result, err 4719 } 4720 tries++ 4721 if tries >= 3 { 4722 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4723 return result, err 4724 } 4725 } 4726 4727} 4728 4729func (s *RetryLayerJobStore) UpdateStatus(id string, status string) (*model.Job, error) { 4730 4731 tries := 0 4732 for { 4733 result, err := s.JobStore.UpdateStatus(id, status) 4734 if err == nil { 4735 return result, nil 4736 } 4737 if !isRepeatableError(err) { 4738 return result, err 4739 } 4740 tries++ 4741 if tries >= 3 { 4742 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4743 return result, err 4744 } 4745 } 4746 4747} 4748 4749func (s *RetryLayerJobStore) UpdateStatusOptimistically(id string, currentStatus string, newStatus string) (bool, error) { 4750 4751 tries := 0 4752 for { 4753 result, err := s.JobStore.UpdateStatusOptimistically(id, currentStatus, newStatus) 4754 if err == nil { 4755 return result, nil 4756 } 4757 if !isRepeatableError(err) { 4758 return result, err 4759 } 4760 tries++ 4761 if tries >= 3 { 4762 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4763 return result, err 4764 } 4765 } 4766 4767} 4768 4769func (s *RetryLayerLicenseStore) Get(id string) (*model.LicenseRecord, error) { 4770 4771 tries := 0 4772 for { 4773 result, err := s.LicenseStore.Get(id) 4774 if err == nil { 4775 return result, nil 4776 } 4777 if !isRepeatableError(err) { 4778 return result, err 4779 } 4780 tries++ 4781 if tries >= 3 { 4782 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4783 return result, err 4784 } 4785 } 4786 4787} 4788 4789func (s *RetryLayerLicenseStore) GetAll() ([]*model.LicenseRecord, error) { 4790 4791 tries := 0 4792 for { 4793 result, err := s.LicenseStore.GetAll() 4794 if err == nil { 4795 return result, nil 4796 } 4797 if !isRepeatableError(err) { 4798 return result, err 4799 } 4800 tries++ 4801 if tries >= 3 { 4802 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4803 return result, err 4804 } 4805 } 4806 4807} 4808 4809func (s *RetryLayerLicenseStore) Save(license *model.LicenseRecord) (*model.LicenseRecord, error) { 4810 4811 tries := 0 4812 for { 4813 result, err := s.LicenseStore.Save(license) 4814 if err == nil { 4815 return result, nil 4816 } 4817 if !isRepeatableError(err) { 4818 return result, err 4819 } 4820 tries++ 4821 if tries >= 3 { 4822 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4823 return result, err 4824 } 4825 } 4826 4827} 4828 4829func (s *RetryLayerLinkMetadataStore) Get(url string, timestamp int64) (*model.LinkMetadata, error) { 4830 4831 tries := 0 4832 for { 4833 result, err := s.LinkMetadataStore.Get(url, timestamp) 4834 if err == nil { 4835 return result, nil 4836 } 4837 if !isRepeatableError(err) { 4838 return result, err 4839 } 4840 tries++ 4841 if tries >= 3 { 4842 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4843 return result, err 4844 } 4845 } 4846 4847} 4848 4849func (s *RetryLayerLinkMetadataStore) Save(linkMetadata *model.LinkMetadata) (*model.LinkMetadata, error) { 4850 4851 tries := 0 4852 for { 4853 result, err := s.LinkMetadataStore.Save(linkMetadata) 4854 if err == nil { 4855 return result, nil 4856 } 4857 if !isRepeatableError(err) { 4858 return result, err 4859 } 4860 tries++ 4861 if tries >= 3 { 4862 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4863 return result, err 4864 } 4865 } 4866 4867} 4868 4869func (s *RetryLayerOAuthStore) DeleteApp(id string) error { 4870 4871 tries := 0 4872 for { 4873 err := s.OAuthStore.DeleteApp(id) 4874 if err == nil { 4875 return nil 4876 } 4877 if !isRepeatableError(err) { 4878 return err 4879 } 4880 tries++ 4881 if tries >= 3 { 4882 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4883 return err 4884 } 4885 } 4886 4887} 4888 4889func (s *RetryLayerOAuthStore) GetAccessData(token string) (*model.AccessData, error) { 4890 4891 tries := 0 4892 for { 4893 result, err := s.OAuthStore.GetAccessData(token) 4894 if err == nil { 4895 return result, nil 4896 } 4897 if !isRepeatableError(err) { 4898 return result, err 4899 } 4900 tries++ 4901 if tries >= 3 { 4902 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4903 return result, err 4904 } 4905 } 4906 4907} 4908 4909func (s *RetryLayerOAuthStore) GetAccessDataByRefreshToken(token string) (*model.AccessData, error) { 4910 4911 tries := 0 4912 for { 4913 result, err := s.OAuthStore.GetAccessDataByRefreshToken(token) 4914 if err == nil { 4915 return result, nil 4916 } 4917 if !isRepeatableError(err) { 4918 return result, err 4919 } 4920 tries++ 4921 if tries >= 3 { 4922 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4923 return result, err 4924 } 4925 } 4926 4927} 4928 4929func (s *RetryLayerOAuthStore) GetAccessDataByUserForApp(userID string, clientId string) ([]*model.AccessData, error) { 4930 4931 tries := 0 4932 for { 4933 result, err := s.OAuthStore.GetAccessDataByUserForApp(userID, clientId) 4934 if err == nil { 4935 return result, nil 4936 } 4937 if !isRepeatableError(err) { 4938 return result, err 4939 } 4940 tries++ 4941 if tries >= 3 { 4942 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4943 return result, err 4944 } 4945 } 4946 4947} 4948 4949func (s *RetryLayerOAuthStore) GetApp(id string) (*model.OAuthApp, error) { 4950 4951 tries := 0 4952 for { 4953 result, err := s.OAuthStore.GetApp(id) 4954 if err == nil { 4955 return result, nil 4956 } 4957 if !isRepeatableError(err) { 4958 return result, err 4959 } 4960 tries++ 4961 if tries >= 3 { 4962 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4963 return result, err 4964 } 4965 } 4966 4967} 4968 4969func (s *RetryLayerOAuthStore) GetAppByUser(userID string, offset int, limit int) ([]*model.OAuthApp, error) { 4970 4971 tries := 0 4972 for { 4973 result, err := s.OAuthStore.GetAppByUser(userID, offset, limit) 4974 if err == nil { 4975 return result, nil 4976 } 4977 if !isRepeatableError(err) { 4978 return result, err 4979 } 4980 tries++ 4981 if tries >= 3 { 4982 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 4983 return result, err 4984 } 4985 } 4986 4987} 4988 4989func (s *RetryLayerOAuthStore) GetApps(offset int, limit int) ([]*model.OAuthApp, error) { 4990 4991 tries := 0 4992 for { 4993 result, err := s.OAuthStore.GetApps(offset, limit) 4994 if err == nil { 4995 return result, nil 4996 } 4997 if !isRepeatableError(err) { 4998 return result, err 4999 } 5000 tries++ 5001 if tries >= 3 { 5002 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5003 return result, err 5004 } 5005 } 5006 5007} 5008 5009func (s *RetryLayerOAuthStore) GetAuthData(code string) (*model.AuthData, error) { 5010 5011 tries := 0 5012 for { 5013 result, err := s.OAuthStore.GetAuthData(code) 5014 if err == nil { 5015 return result, nil 5016 } 5017 if !isRepeatableError(err) { 5018 return result, err 5019 } 5020 tries++ 5021 if tries >= 3 { 5022 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5023 return result, err 5024 } 5025 } 5026 5027} 5028 5029func (s *RetryLayerOAuthStore) GetAuthorizedApps(userID string, offset int, limit int) ([]*model.OAuthApp, error) { 5030 5031 tries := 0 5032 for { 5033 result, err := s.OAuthStore.GetAuthorizedApps(userID, offset, limit) 5034 if err == nil { 5035 return result, nil 5036 } 5037 if !isRepeatableError(err) { 5038 return result, err 5039 } 5040 tries++ 5041 if tries >= 3 { 5042 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5043 return result, err 5044 } 5045 } 5046 5047} 5048 5049func (s *RetryLayerOAuthStore) GetPreviousAccessData(userID string, clientId string) (*model.AccessData, error) { 5050 5051 tries := 0 5052 for { 5053 result, err := s.OAuthStore.GetPreviousAccessData(userID, clientId) 5054 if err == nil { 5055 return result, nil 5056 } 5057 if !isRepeatableError(err) { 5058 return result, err 5059 } 5060 tries++ 5061 if tries >= 3 { 5062 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5063 return result, err 5064 } 5065 } 5066 5067} 5068 5069func (s *RetryLayerOAuthStore) PermanentDeleteAuthDataByUser(userID string) error { 5070 5071 tries := 0 5072 for { 5073 err := s.OAuthStore.PermanentDeleteAuthDataByUser(userID) 5074 if err == nil { 5075 return nil 5076 } 5077 if !isRepeatableError(err) { 5078 return err 5079 } 5080 tries++ 5081 if tries >= 3 { 5082 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5083 return err 5084 } 5085 } 5086 5087} 5088 5089func (s *RetryLayerOAuthStore) RemoveAccessData(token string) error { 5090 5091 tries := 0 5092 for { 5093 err := s.OAuthStore.RemoveAccessData(token) 5094 if err == nil { 5095 return nil 5096 } 5097 if !isRepeatableError(err) { 5098 return err 5099 } 5100 tries++ 5101 if tries >= 3 { 5102 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5103 return err 5104 } 5105 } 5106 5107} 5108 5109func (s *RetryLayerOAuthStore) RemoveAllAccessData() error { 5110 5111 tries := 0 5112 for { 5113 err := s.OAuthStore.RemoveAllAccessData() 5114 if err == nil { 5115 return nil 5116 } 5117 if !isRepeatableError(err) { 5118 return err 5119 } 5120 tries++ 5121 if tries >= 3 { 5122 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5123 return err 5124 } 5125 } 5126 5127} 5128 5129func (s *RetryLayerOAuthStore) RemoveAuthData(code string) error { 5130 5131 tries := 0 5132 for { 5133 err := s.OAuthStore.RemoveAuthData(code) 5134 if err == nil { 5135 return nil 5136 } 5137 if !isRepeatableError(err) { 5138 return err 5139 } 5140 tries++ 5141 if tries >= 3 { 5142 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5143 return err 5144 } 5145 } 5146 5147} 5148 5149func (s *RetryLayerOAuthStore) SaveAccessData(accessData *model.AccessData) (*model.AccessData, error) { 5150 5151 tries := 0 5152 for { 5153 result, err := s.OAuthStore.SaveAccessData(accessData) 5154 if err == nil { 5155 return result, nil 5156 } 5157 if !isRepeatableError(err) { 5158 return result, err 5159 } 5160 tries++ 5161 if tries >= 3 { 5162 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5163 return result, err 5164 } 5165 } 5166 5167} 5168 5169func (s *RetryLayerOAuthStore) SaveApp(app *model.OAuthApp) (*model.OAuthApp, error) { 5170 5171 tries := 0 5172 for { 5173 result, err := s.OAuthStore.SaveApp(app) 5174 if err == nil { 5175 return result, nil 5176 } 5177 if !isRepeatableError(err) { 5178 return result, err 5179 } 5180 tries++ 5181 if tries >= 3 { 5182 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5183 return result, err 5184 } 5185 } 5186 5187} 5188 5189func (s *RetryLayerOAuthStore) SaveAuthData(authData *model.AuthData) (*model.AuthData, error) { 5190 5191 tries := 0 5192 for { 5193 result, err := s.OAuthStore.SaveAuthData(authData) 5194 if err == nil { 5195 return result, nil 5196 } 5197 if !isRepeatableError(err) { 5198 return result, err 5199 } 5200 tries++ 5201 if tries >= 3 { 5202 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5203 return result, err 5204 } 5205 } 5206 5207} 5208 5209func (s *RetryLayerOAuthStore) UpdateAccessData(accessData *model.AccessData) (*model.AccessData, error) { 5210 5211 tries := 0 5212 for { 5213 result, err := s.OAuthStore.UpdateAccessData(accessData) 5214 if err == nil { 5215 return result, nil 5216 } 5217 if !isRepeatableError(err) { 5218 return result, err 5219 } 5220 tries++ 5221 if tries >= 3 { 5222 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5223 return result, err 5224 } 5225 } 5226 5227} 5228 5229func (s *RetryLayerOAuthStore) UpdateApp(app *model.OAuthApp) (*model.OAuthApp, error) { 5230 5231 tries := 0 5232 for { 5233 result, err := s.OAuthStore.UpdateApp(app) 5234 if err == nil { 5235 return result, nil 5236 } 5237 if !isRepeatableError(err) { 5238 return result, err 5239 } 5240 tries++ 5241 if tries >= 3 { 5242 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5243 return result, err 5244 } 5245 } 5246 5247} 5248 5249func (s *RetryLayerPluginStore) CompareAndDelete(keyVal *model.PluginKeyValue, oldValue []byte) (bool, error) { 5250 5251 tries := 0 5252 for { 5253 result, err := s.PluginStore.CompareAndDelete(keyVal, oldValue) 5254 if err == nil { 5255 return result, nil 5256 } 5257 if !isRepeatableError(err) { 5258 return result, err 5259 } 5260 tries++ 5261 if tries >= 3 { 5262 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5263 return result, err 5264 } 5265 } 5266 5267} 5268 5269func (s *RetryLayerPluginStore) CompareAndSet(keyVal *model.PluginKeyValue, oldValue []byte) (bool, error) { 5270 5271 tries := 0 5272 for { 5273 result, err := s.PluginStore.CompareAndSet(keyVal, oldValue) 5274 if err == nil { 5275 return result, nil 5276 } 5277 if !isRepeatableError(err) { 5278 return result, err 5279 } 5280 tries++ 5281 if tries >= 3 { 5282 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5283 return result, err 5284 } 5285 } 5286 5287} 5288 5289func (s *RetryLayerPluginStore) Delete(pluginID string, key string) error { 5290 5291 tries := 0 5292 for { 5293 err := s.PluginStore.Delete(pluginID, key) 5294 if err == nil { 5295 return nil 5296 } 5297 if !isRepeatableError(err) { 5298 return err 5299 } 5300 tries++ 5301 if tries >= 3 { 5302 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5303 return err 5304 } 5305 } 5306 5307} 5308 5309func (s *RetryLayerPluginStore) DeleteAllExpired() error { 5310 5311 tries := 0 5312 for { 5313 err := s.PluginStore.DeleteAllExpired() 5314 if err == nil { 5315 return nil 5316 } 5317 if !isRepeatableError(err) { 5318 return err 5319 } 5320 tries++ 5321 if tries >= 3 { 5322 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5323 return err 5324 } 5325 } 5326 5327} 5328 5329func (s *RetryLayerPluginStore) DeleteAllForPlugin(PluginID string) error { 5330 5331 tries := 0 5332 for { 5333 err := s.PluginStore.DeleteAllForPlugin(PluginID) 5334 if err == nil { 5335 return nil 5336 } 5337 if !isRepeatableError(err) { 5338 return err 5339 } 5340 tries++ 5341 if tries >= 3 { 5342 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5343 return err 5344 } 5345 } 5346 5347} 5348 5349func (s *RetryLayerPluginStore) Get(pluginID string, key string) (*model.PluginKeyValue, error) { 5350 5351 tries := 0 5352 for { 5353 result, err := s.PluginStore.Get(pluginID, key) 5354 if err == nil { 5355 return result, nil 5356 } 5357 if !isRepeatableError(err) { 5358 return result, err 5359 } 5360 tries++ 5361 if tries >= 3 { 5362 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5363 return result, err 5364 } 5365 } 5366 5367} 5368 5369func (s *RetryLayerPluginStore) List(pluginID string, page int, perPage int) ([]string, error) { 5370 5371 tries := 0 5372 for { 5373 result, err := s.PluginStore.List(pluginID, page, perPage) 5374 if err == nil { 5375 return result, nil 5376 } 5377 if !isRepeatableError(err) { 5378 return result, err 5379 } 5380 tries++ 5381 if tries >= 3 { 5382 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5383 return result, err 5384 } 5385 } 5386 5387} 5388 5389func (s *RetryLayerPluginStore) SaveOrUpdate(keyVal *model.PluginKeyValue) (*model.PluginKeyValue, error) { 5390 5391 tries := 0 5392 for { 5393 result, err := s.PluginStore.SaveOrUpdate(keyVal) 5394 if err == nil { 5395 return result, nil 5396 } 5397 if !isRepeatableError(err) { 5398 return result, err 5399 } 5400 tries++ 5401 if tries >= 3 { 5402 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5403 return result, err 5404 } 5405 } 5406 5407} 5408 5409func (s *RetryLayerPluginStore) SetWithOptions(pluginID string, key string, value []byte, options model.PluginKVSetOptions) (bool, error) { 5410 5411 tries := 0 5412 for { 5413 result, err := s.PluginStore.SetWithOptions(pluginID, key, value, options) 5414 if err == nil { 5415 return result, nil 5416 } 5417 if !isRepeatableError(err) { 5418 return result, err 5419 } 5420 tries++ 5421 if tries >= 3 { 5422 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5423 return result, err 5424 } 5425 } 5426 5427} 5428 5429func (s *RetryLayerPostStore) AnalyticsPostCount(teamID string, mustHaveFile bool, mustHaveHashtag bool) (int64, error) { 5430 5431 tries := 0 5432 for { 5433 result, err := s.PostStore.AnalyticsPostCount(teamID, mustHaveFile, mustHaveHashtag) 5434 if err == nil { 5435 return result, nil 5436 } 5437 if !isRepeatableError(err) { 5438 return result, err 5439 } 5440 tries++ 5441 if tries >= 3 { 5442 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5443 return result, err 5444 } 5445 } 5446 5447} 5448 5449func (s *RetryLayerPostStore) AnalyticsPostCountsByDay(options *model.AnalyticsPostCountsOptions) (model.AnalyticsRows, error) { 5450 5451 tries := 0 5452 for { 5453 result, err := s.PostStore.AnalyticsPostCountsByDay(options) 5454 if err == nil { 5455 return result, nil 5456 } 5457 if !isRepeatableError(err) { 5458 return result, err 5459 } 5460 tries++ 5461 if tries >= 3 { 5462 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5463 return result, err 5464 } 5465 } 5466 5467} 5468 5469func (s *RetryLayerPostStore) AnalyticsUserCountsWithPostsByDay(teamID string) (model.AnalyticsRows, error) { 5470 5471 tries := 0 5472 for { 5473 result, err := s.PostStore.AnalyticsUserCountsWithPostsByDay(teamID) 5474 if err == nil { 5475 return result, nil 5476 } 5477 if !isRepeatableError(err) { 5478 return result, err 5479 } 5480 tries++ 5481 if tries >= 3 { 5482 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5483 return result, err 5484 } 5485 } 5486 5487} 5488 5489func (s *RetryLayerPostStore) ClearCaches() { 5490 5491 s.PostStore.ClearCaches() 5492 5493} 5494 5495func (s *RetryLayerPostStore) Delete(postID string, time int64, deleteByID string) error { 5496 5497 tries := 0 5498 for { 5499 err := s.PostStore.Delete(postID, time, deleteByID) 5500 if err == nil { 5501 return nil 5502 } 5503 if !isRepeatableError(err) { 5504 return err 5505 } 5506 tries++ 5507 if tries >= 3 { 5508 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5509 return err 5510 } 5511 } 5512 5513} 5514 5515func (s *RetryLayerPostStore) DeleteOrphanedRows(limit int) (int64, error) { 5516 5517 tries := 0 5518 for { 5519 result, err := s.PostStore.DeleteOrphanedRows(limit) 5520 if err == nil { 5521 return result, nil 5522 } 5523 if !isRepeatableError(err) { 5524 return result, err 5525 } 5526 tries++ 5527 if tries >= 3 { 5528 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5529 return result, err 5530 } 5531 } 5532 5533} 5534 5535func (s *RetryLayerPostStore) Get(ctx context.Context, id string, skipFetchThreads bool, collapsedThreads bool, collapsedThreadsExtended bool, userID string) (*model.PostList, error) { 5536 5537 tries := 0 5538 for { 5539 result, err := s.PostStore.Get(ctx, id, skipFetchThreads, collapsedThreads, collapsedThreadsExtended, userID) 5540 if err == nil { 5541 return result, nil 5542 } 5543 if !isRepeatableError(err) { 5544 return result, err 5545 } 5546 tries++ 5547 if tries >= 3 { 5548 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5549 return result, err 5550 } 5551 } 5552 5553} 5554 5555func (s *RetryLayerPostStore) GetDirectPostParentsForExportAfter(limit int, afterID string) ([]*model.DirectPostForExport, error) { 5556 5557 tries := 0 5558 for { 5559 result, err := s.PostStore.GetDirectPostParentsForExportAfter(limit, afterID) 5560 if err == nil { 5561 return result, nil 5562 } 5563 if !isRepeatableError(err) { 5564 return result, err 5565 } 5566 tries++ 5567 if tries >= 3 { 5568 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5569 return result, err 5570 } 5571 } 5572 5573} 5574 5575func (s *RetryLayerPostStore) GetEtag(channelID string, allowFromCache bool, collapsedThreads bool) string { 5576 5577 return s.PostStore.GetEtag(channelID, allowFromCache, collapsedThreads) 5578 5579} 5580 5581func (s *RetryLayerPostStore) GetFlaggedPosts(userID string, offset int, limit int) (*model.PostList, error) { 5582 5583 tries := 0 5584 for { 5585 result, err := s.PostStore.GetFlaggedPosts(userID, offset, limit) 5586 if err == nil { 5587 return result, nil 5588 } 5589 if !isRepeatableError(err) { 5590 return result, err 5591 } 5592 tries++ 5593 if tries >= 3 { 5594 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5595 return result, err 5596 } 5597 } 5598 5599} 5600 5601func (s *RetryLayerPostStore) GetFlaggedPostsForChannel(userID string, channelID string, offset int, limit int) (*model.PostList, error) { 5602 5603 tries := 0 5604 for { 5605 result, err := s.PostStore.GetFlaggedPostsForChannel(userID, channelID, offset, limit) 5606 if err == nil { 5607 return result, nil 5608 } 5609 if !isRepeatableError(err) { 5610 return result, err 5611 } 5612 tries++ 5613 if tries >= 3 { 5614 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5615 return result, err 5616 } 5617 } 5618 5619} 5620 5621func (s *RetryLayerPostStore) GetFlaggedPostsForTeam(userID string, teamID string, offset int, limit int) (*model.PostList, error) { 5622 5623 tries := 0 5624 for { 5625 result, err := s.PostStore.GetFlaggedPostsForTeam(userID, teamID, offset, limit) 5626 if err == nil { 5627 return result, nil 5628 } 5629 if !isRepeatableError(err) { 5630 return result, err 5631 } 5632 tries++ 5633 if tries >= 3 { 5634 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5635 return result, err 5636 } 5637 } 5638 5639} 5640 5641func (s *RetryLayerPostStore) GetMaxPostSize() int { 5642 5643 return s.PostStore.GetMaxPostSize() 5644 5645} 5646 5647func (s *RetryLayerPostStore) GetOldest() (*model.Post, error) { 5648 5649 tries := 0 5650 for { 5651 result, err := s.PostStore.GetOldest() 5652 if err == nil { 5653 return result, nil 5654 } 5655 if !isRepeatableError(err) { 5656 return result, err 5657 } 5658 tries++ 5659 if tries >= 3 { 5660 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5661 return result, err 5662 } 5663 } 5664 5665} 5666 5667func (s *RetryLayerPostStore) GetOldestEntityCreationTime() (int64, error) { 5668 5669 tries := 0 5670 for { 5671 result, err := s.PostStore.GetOldestEntityCreationTime() 5672 if err == nil { 5673 return result, nil 5674 } 5675 if !isRepeatableError(err) { 5676 return result, err 5677 } 5678 tries++ 5679 if tries >= 3 { 5680 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5681 return result, err 5682 } 5683 } 5684 5685} 5686 5687func (s *RetryLayerPostStore) GetParentsForExportAfter(limit int, afterID string) ([]*model.PostForExport, error) { 5688 5689 tries := 0 5690 for { 5691 result, err := s.PostStore.GetParentsForExportAfter(limit, afterID) 5692 if err == nil { 5693 return result, nil 5694 } 5695 if !isRepeatableError(err) { 5696 return result, err 5697 } 5698 tries++ 5699 if tries >= 3 { 5700 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5701 return result, err 5702 } 5703 } 5704 5705} 5706 5707func (s *RetryLayerPostStore) GetPostAfterTime(channelID string, time int64, collapsedThreads bool) (*model.Post, error) { 5708 5709 tries := 0 5710 for { 5711 result, err := s.PostStore.GetPostAfterTime(channelID, time, collapsedThreads) 5712 if err == nil { 5713 return result, nil 5714 } 5715 if !isRepeatableError(err) { 5716 return result, err 5717 } 5718 tries++ 5719 if tries >= 3 { 5720 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5721 return result, err 5722 } 5723 } 5724 5725} 5726 5727func (s *RetryLayerPostStore) GetPostIdAfterTime(channelID string, time int64, collapsedThreads bool) (string, error) { 5728 5729 tries := 0 5730 for { 5731 result, err := s.PostStore.GetPostIdAfterTime(channelID, time, collapsedThreads) 5732 if err == nil { 5733 return result, nil 5734 } 5735 if !isRepeatableError(err) { 5736 return result, err 5737 } 5738 tries++ 5739 if tries >= 3 { 5740 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5741 return result, err 5742 } 5743 } 5744 5745} 5746 5747func (s *RetryLayerPostStore) GetPostIdBeforeTime(channelID string, time int64, collapsedThreads bool) (string, error) { 5748 5749 tries := 0 5750 for { 5751 result, err := s.PostStore.GetPostIdBeforeTime(channelID, time, collapsedThreads) 5752 if err == nil { 5753 return result, nil 5754 } 5755 if !isRepeatableError(err) { 5756 return result, err 5757 } 5758 tries++ 5759 if tries >= 3 { 5760 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5761 return result, err 5762 } 5763 } 5764 5765} 5766 5767func (s *RetryLayerPostStore) GetPosts(options model.GetPostsOptions, allowFromCache bool) (*model.PostList, error) { 5768 5769 tries := 0 5770 for { 5771 result, err := s.PostStore.GetPosts(options, allowFromCache) 5772 if err == nil { 5773 return result, nil 5774 } 5775 if !isRepeatableError(err) { 5776 return result, err 5777 } 5778 tries++ 5779 if tries >= 3 { 5780 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5781 return result, err 5782 } 5783 } 5784 5785} 5786 5787func (s *RetryLayerPostStore) GetPostsAfter(options model.GetPostsOptions) (*model.PostList, error) { 5788 5789 tries := 0 5790 for { 5791 result, err := s.PostStore.GetPostsAfter(options) 5792 if err == nil { 5793 return result, nil 5794 } 5795 if !isRepeatableError(err) { 5796 return result, err 5797 } 5798 tries++ 5799 if tries >= 3 { 5800 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5801 return result, err 5802 } 5803 } 5804 5805} 5806 5807func (s *RetryLayerPostStore) GetPostsBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.PostForIndexing, error) { 5808 5809 tries := 0 5810 for { 5811 result, err := s.PostStore.GetPostsBatchForIndexing(startTime, endTime, limit) 5812 if err == nil { 5813 return result, nil 5814 } 5815 if !isRepeatableError(err) { 5816 return result, err 5817 } 5818 tries++ 5819 if tries >= 3 { 5820 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5821 return result, err 5822 } 5823 } 5824 5825} 5826 5827func (s *RetryLayerPostStore) GetPostsBefore(options model.GetPostsOptions) (*model.PostList, error) { 5828 5829 tries := 0 5830 for { 5831 result, err := s.PostStore.GetPostsBefore(options) 5832 if err == nil { 5833 return result, nil 5834 } 5835 if !isRepeatableError(err) { 5836 return result, err 5837 } 5838 tries++ 5839 if tries >= 3 { 5840 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5841 return result, err 5842 } 5843 } 5844 5845} 5846 5847func (s *RetryLayerPostStore) GetPostsByIds(postIds []string) ([]*model.Post, error) { 5848 5849 tries := 0 5850 for { 5851 result, err := s.PostStore.GetPostsByIds(postIds) 5852 if err == nil { 5853 return result, nil 5854 } 5855 if !isRepeatableError(err) { 5856 return result, err 5857 } 5858 tries++ 5859 if tries >= 3 { 5860 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5861 return result, err 5862 } 5863 } 5864 5865} 5866 5867func (s *RetryLayerPostStore) GetPostsCreatedAt(channelID string, time int64) ([]*model.Post, error) { 5868 5869 tries := 0 5870 for { 5871 result, err := s.PostStore.GetPostsCreatedAt(channelID, time) 5872 if err == nil { 5873 return result, nil 5874 } 5875 if !isRepeatableError(err) { 5876 return result, err 5877 } 5878 tries++ 5879 if tries >= 3 { 5880 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5881 return result, err 5882 } 5883 } 5884 5885} 5886 5887func (s *RetryLayerPostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFromCache bool) (*model.PostList, error) { 5888 5889 tries := 0 5890 for { 5891 result, err := s.PostStore.GetPostsSince(options, allowFromCache) 5892 if err == nil { 5893 return result, nil 5894 } 5895 if !isRepeatableError(err) { 5896 return result, err 5897 } 5898 tries++ 5899 if tries >= 3 { 5900 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5901 return result, err 5902 } 5903 } 5904 5905} 5906 5907func (s *RetryLayerPostStore) GetPostsSinceForSync(options model.GetPostsSinceForSyncOptions, cursor model.GetPostsSinceForSyncCursor, limit int) ([]*model.Post, model.GetPostsSinceForSyncCursor, error) { 5908 5909 tries := 0 5910 for { 5911 result, resultVar1, err := s.PostStore.GetPostsSinceForSync(options, cursor, limit) 5912 if err == nil { 5913 return result, resultVar1, nil 5914 } 5915 if !isRepeatableError(err) { 5916 return result, resultVar1, err 5917 } 5918 tries++ 5919 if tries >= 3 { 5920 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5921 return result, resultVar1, err 5922 } 5923 } 5924 5925} 5926 5927func (s *RetryLayerPostStore) GetRepliesForExport(parentID string) ([]*model.ReplyForExport, error) { 5928 5929 tries := 0 5930 for { 5931 result, err := s.PostStore.GetRepliesForExport(parentID) 5932 if err == nil { 5933 return result, nil 5934 } 5935 if !isRepeatableError(err) { 5936 return result, err 5937 } 5938 tries++ 5939 if tries >= 3 { 5940 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5941 return result, err 5942 } 5943 } 5944 5945} 5946 5947func (s *RetryLayerPostStore) GetSingle(id string, inclDeleted bool) (*model.Post, error) { 5948 5949 tries := 0 5950 for { 5951 result, err := s.PostStore.GetSingle(id, inclDeleted) 5952 if err == nil { 5953 return result, nil 5954 } 5955 if !isRepeatableError(err) { 5956 return result, err 5957 } 5958 tries++ 5959 if tries >= 3 { 5960 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5961 return result, err 5962 } 5963 } 5964 5965} 5966 5967func (s *RetryLayerPostStore) HasAutoResponsePostByUserSince(options model.GetPostsSinceOptions, userId string) (bool, error) { 5968 5969 tries := 0 5970 for { 5971 result, err := s.PostStore.HasAutoResponsePostByUserSince(options, userId) 5972 if err == nil { 5973 return result, nil 5974 } 5975 if !isRepeatableError(err) { 5976 return result, err 5977 } 5978 tries++ 5979 if tries >= 3 { 5980 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 5981 return result, err 5982 } 5983 } 5984 5985} 5986 5987func (s *RetryLayerPostStore) InvalidateLastPostTimeCache(channelID string) { 5988 5989 s.PostStore.InvalidateLastPostTimeCache(channelID) 5990 5991} 5992 5993func (s *RetryLayerPostStore) Overwrite(post *model.Post) (*model.Post, error) { 5994 5995 tries := 0 5996 for { 5997 result, err := s.PostStore.Overwrite(post) 5998 if err == nil { 5999 return result, nil 6000 } 6001 if !isRepeatableError(err) { 6002 return result, err 6003 } 6004 tries++ 6005 if tries >= 3 { 6006 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6007 return result, err 6008 } 6009 } 6010 6011} 6012 6013func (s *RetryLayerPostStore) OverwriteMultiple(posts []*model.Post) ([]*model.Post, int, error) { 6014 6015 tries := 0 6016 for { 6017 result, resultVar1, err := s.PostStore.OverwriteMultiple(posts) 6018 if err == nil { 6019 return result, resultVar1, nil 6020 } 6021 if !isRepeatableError(err) { 6022 return result, resultVar1, err 6023 } 6024 tries++ 6025 if tries >= 3 { 6026 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6027 return result, resultVar1, err 6028 } 6029 } 6030 6031} 6032 6033func (s *RetryLayerPostStore) PermanentDeleteBatch(endTime int64, limit int64) (int64, error) { 6034 6035 tries := 0 6036 for { 6037 result, err := s.PostStore.PermanentDeleteBatch(endTime, limit) 6038 if err == nil { 6039 return result, nil 6040 } 6041 if !isRepeatableError(err) { 6042 return result, err 6043 } 6044 tries++ 6045 if tries >= 3 { 6046 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6047 return result, err 6048 } 6049 } 6050 6051} 6052 6053func (s *RetryLayerPostStore) PermanentDeleteBatchForRetentionPolicies(now int64, globalPolicyEndTime int64, limit int64, cursor model.RetentionPolicyCursor) (int64, model.RetentionPolicyCursor, error) { 6054 6055 tries := 0 6056 for { 6057 result, resultVar1, err := s.PostStore.PermanentDeleteBatchForRetentionPolicies(now, globalPolicyEndTime, limit, cursor) 6058 if err == nil { 6059 return result, resultVar1, nil 6060 } 6061 if !isRepeatableError(err) { 6062 return result, resultVar1, err 6063 } 6064 tries++ 6065 if tries >= 3 { 6066 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6067 return result, resultVar1, err 6068 } 6069 } 6070 6071} 6072 6073func (s *RetryLayerPostStore) PermanentDeleteByChannel(channelID string) error { 6074 6075 tries := 0 6076 for { 6077 err := s.PostStore.PermanentDeleteByChannel(channelID) 6078 if err == nil { 6079 return nil 6080 } 6081 if !isRepeatableError(err) { 6082 return err 6083 } 6084 tries++ 6085 if tries >= 3 { 6086 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6087 return err 6088 } 6089 } 6090 6091} 6092 6093func (s *RetryLayerPostStore) PermanentDeleteByUser(userID string) error { 6094 6095 tries := 0 6096 for { 6097 err := s.PostStore.PermanentDeleteByUser(userID) 6098 if err == nil { 6099 return nil 6100 } 6101 if !isRepeatableError(err) { 6102 return err 6103 } 6104 tries++ 6105 if tries >= 3 { 6106 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6107 return err 6108 } 6109 } 6110 6111} 6112 6113func (s *RetryLayerPostStore) Save(post *model.Post) (*model.Post, error) { 6114 6115 tries := 0 6116 for { 6117 result, err := s.PostStore.Save(post) 6118 if err == nil { 6119 return result, nil 6120 } 6121 if !isRepeatableError(err) { 6122 return result, err 6123 } 6124 tries++ 6125 if tries >= 3 { 6126 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6127 return result, err 6128 } 6129 } 6130 6131} 6132 6133func (s *RetryLayerPostStore) SaveMultiple(posts []*model.Post) ([]*model.Post, int, error) { 6134 6135 tries := 0 6136 for { 6137 result, resultVar1, err := s.PostStore.SaveMultiple(posts) 6138 if err == nil { 6139 return result, resultVar1, nil 6140 } 6141 if !isRepeatableError(err) { 6142 return result, resultVar1, err 6143 } 6144 tries++ 6145 if tries >= 3 { 6146 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6147 return result, resultVar1, err 6148 } 6149 } 6150 6151} 6152 6153func (s *RetryLayerPostStore) Search(teamID string, userID string, params *model.SearchParams) (*model.PostList, error) { 6154 6155 tries := 0 6156 for { 6157 result, err := s.PostStore.Search(teamID, userID, params) 6158 if err == nil { 6159 return result, nil 6160 } 6161 if !isRepeatableError(err) { 6162 return result, err 6163 } 6164 tries++ 6165 if tries >= 3 { 6166 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6167 return result, err 6168 } 6169 } 6170 6171} 6172 6173func (s *RetryLayerPostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams, userID string, teamID string, page int, perPage int) (*model.PostSearchResults, error) { 6174 6175 tries := 0 6176 for { 6177 result, err := s.PostStore.SearchPostsInTeamForUser(paramsList, userID, teamID, page, perPage) 6178 if err == nil { 6179 return result, nil 6180 } 6181 if !isRepeatableError(err) { 6182 return result, err 6183 } 6184 tries++ 6185 if tries >= 3 { 6186 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6187 return result, err 6188 } 6189 } 6190 6191} 6192 6193func (s *RetryLayerPostStore) Update(newPost *model.Post, oldPost *model.Post) (*model.Post, error) { 6194 6195 tries := 0 6196 for { 6197 result, err := s.PostStore.Update(newPost, oldPost) 6198 if err == nil { 6199 return result, nil 6200 } 6201 if !isRepeatableError(err) { 6202 return result, err 6203 } 6204 tries++ 6205 if tries >= 3 { 6206 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6207 return result, err 6208 } 6209 } 6210 6211} 6212 6213func (s *RetryLayerPreferenceStore) CleanupFlagsBatch(limit int64) (int64, error) { 6214 6215 tries := 0 6216 for { 6217 result, err := s.PreferenceStore.CleanupFlagsBatch(limit) 6218 if err == nil { 6219 return result, nil 6220 } 6221 if !isRepeatableError(err) { 6222 return result, err 6223 } 6224 tries++ 6225 if tries >= 3 { 6226 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6227 return result, err 6228 } 6229 } 6230 6231} 6232 6233func (s *RetryLayerPreferenceStore) Delete(userID string, category string, name string) error { 6234 6235 tries := 0 6236 for { 6237 err := s.PreferenceStore.Delete(userID, category, name) 6238 if err == nil { 6239 return nil 6240 } 6241 if !isRepeatableError(err) { 6242 return err 6243 } 6244 tries++ 6245 if tries >= 3 { 6246 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6247 return err 6248 } 6249 } 6250 6251} 6252 6253func (s *RetryLayerPreferenceStore) DeleteCategory(userID string, category string) error { 6254 6255 tries := 0 6256 for { 6257 err := s.PreferenceStore.DeleteCategory(userID, category) 6258 if err == nil { 6259 return nil 6260 } 6261 if !isRepeatableError(err) { 6262 return err 6263 } 6264 tries++ 6265 if tries >= 3 { 6266 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6267 return err 6268 } 6269 } 6270 6271} 6272 6273func (s *RetryLayerPreferenceStore) DeleteCategoryAndName(category string, name string) error { 6274 6275 tries := 0 6276 for { 6277 err := s.PreferenceStore.DeleteCategoryAndName(category, name) 6278 if err == nil { 6279 return nil 6280 } 6281 if !isRepeatableError(err) { 6282 return err 6283 } 6284 tries++ 6285 if tries >= 3 { 6286 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6287 return err 6288 } 6289 } 6290 6291} 6292 6293func (s *RetryLayerPreferenceStore) DeleteOrphanedRows(limit int) (int64, error) { 6294 6295 tries := 0 6296 for { 6297 result, err := s.PreferenceStore.DeleteOrphanedRows(limit) 6298 if err == nil { 6299 return result, nil 6300 } 6301 if !isRepeatableError(err) { 6302 return result, err 6303 } 6304 tries++ 6305 if tries >= 3 { 6306 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6307 return result, err 6308 } 6309 } 6310 6311} 6312 6313func (s *RetryLayerPreferenceStore) Get(userID string, category string, name string) (*model.Preference, error) { 6314 6315 tries := 0 6316 for { 6317 result, err := s.PreferenceStore.Get(userID, category, name) 6318 if err == nil { 6319 return result, nil 6320 } 6321 if !isRepeatableError(err) { 6322 return result, err 6323 } 6324 tries++ 6325 if tries >= 3 { 6326 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6327 return result, err 6328 } 6329 } 6330 6331} 6332 6333func (s *RetryLayerPreferenceStore) GetAll(userID string) (model.Preferences, error) { 6334 6335 tries := 0 6336 for { 6337 result, err := s.PreferenceStore.GetAll(userID) 6338 if err == nil { 6339 return result, nil 6340 } 6341 if !isRepeatableError(err) { 6342 return result, err 6343 } 6344 tries++ 6345 if tries >= 3 { 6346 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6347 return result, err 6348 } 6349 } 6350 6351} 6352 6353func (s *RetryLayerPreferenceStore) GetCategory(userID string, category string) (model.Preferences, error) { 6354 6355 tries := 0 6356 for { 6357 result, err := s.PreferenceStore.GetCategory(userID, category) 6358 if err == nil { 6359 return result, nil 6360 } 6361 if !isRepeatableError(err) { 6362 return result, err 6363 } 6364 tries++ 6365 if tries >= 3 { 6366 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6367 return result, err 6368 } 6369 } 6370 6371} 6372 6373func (s *RetryLayerPreferenceStore) PermanentDeleteByUser(userID string) error { 6374 6375 tries := 0 6376 for { 6377 err := s.PreferenceStore.PermanentDeleteByUser(userID) 6378 if err == nil { 6379 return nil 6380 } 6381 if !isRepeatableError(err) { 6382 return err 6383 } 6384 tries++ 6385 if tries >= 3 { 6386 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6387 return err 6388 } 6389 } 6390 6391} 6392 6393func (s *RetryLayerPreferenceStore) Save(preferences model.Preferences) error { 6394 6395 tries := 0 6396 for { 6397 err := s.PreferenceStore.Save(preferences) 6398 if err == nil { 6399 return nil 6400 } 6401 if !isRepeatableError(err) { 6402 return err 6403 } 6404 tries++ 6405 if tries >= 3 { 6406 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6407 return err 6408 } 6409 } 6410 6411} 6412 6413func (s *RetryLayerProductNoticesStore) Clear(notices []string) error { 6414 6415 tries := 0 6416 for { 6417 err := s.ProductNoticesStore.Clear(notices) 6418 if err == nil { 6419 return nil 6420 } 6421 if !isRepeatableError(err) { 6422 return err 6423 } 6424 tries++ 6425 if tries >= 3 { 6426 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6427 return err 6428 } 6429 } 6430 6431} 6432 6433func (s *RetryLayerProductNoticesStore) ClearOldNotices(currentNotices model.ProductNotices) error { 6434 6435 tries := 0 6436 for { 6437 err := s.ProductNoticesStore.ClearOldNotices(currentNotices) 6438 if err == nil { 6439 return nil 6440 } 6441 if !isRepeatableError(err) { 6442 return err 6443 } 6444 tries++ 6445 if tries >= 3 { 6446 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6447 return err 6448 } 6449 } 6450 6451} 6452 6453func (s *RetryLayerProductNoticesStore) GetViews(userID string) ([]model.ProductNoticeViewState, error) { 6454 6455 tries := 0 6456 for { 6457 result, err := s.ProductNoticesStore.GetViews(userID) 6458 if err == nil { 6459 return result, nil 6460 } 6461 if !isRepeatableError(err) { 6462 return result, err 6463 } 6464 tries++ 6465 if tries >= 3 { 6466 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6467 return result, err 6468 } 6469 } 6470 6471} 6472 6473func (s *RetryLayerProductNoticesStore) View(userID string, notices []string) error { 6474 6475 tries := 0 6476 for { 6477 err := s.ProductNoticesStore.View(userID, notices) 6478 if err == nil { 6479 return nil 6480 } 6481 if !isRepeatableError(err) { 6482 return err 6483 } 6484 tries++ 6485 if tries >= 3 { 6486 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6487 return err 6488 } 6489 } 6490 6491} 6492 6493func (s *RetryLayerReactionStore) BulkGetForPosts(postIds []string) ([]*model.Reaction, error) { 6494 6495 tries := 0 6496 for { 6497 result, err := s.ReactionStore.BulkGetForPosts(postIds) 6498 if err == nil { 6499 return result, nil 6500 } 6501 if !isRepeatableError(err) { 6502 return result, err 6503 } 6504 tries++ 6505 if tries >= 3 { 6506 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6507 return result, err 6508 } 6509 } 6510 6511} 6512 6513func (s *RetryLayerReactionStore) Delete(reaction *model.Reaction) (*model.Reaction, error) { 6514 6515 tries := 0 6516 for { 6517 result, err := s.ReactionStore.Delete(reaction) 6518 if err == nil { 6519 return result, nil 6520 } 6521 if !isRepeatableError(err) { 6522 return result, err 6523 } 6524 tries++ 6525 if tries >= 3 { 6526 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6527 return result, err 6528 } 6529 } 6530 6531} 6532 6533func (s *RetryLayerReactionStore) DeleteAllWithEmojiName(emojiName string) error { 6534 6535 tries := 0 6536 for { 6537 err := s.ReactionStore.DeleteAllWithEmojiName(emojiName) 6538 if err == nil { 6539 return nil 6540 } 6541 if !isRepeatableError(err) { 6542 return err 6543 } 6544 tries++ 6545 if tries >= 3 { 6546 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6547 return err 6548 } 6549 } 6550 6551} 6552 6553func (s *RetryLayerReactionStore) DeleteOrphanedRows(limit int) (int64, error) { 6554 6555 tries := 0 6556 for { 6557 result, err := s.ReactionStore.DeleteOrphanedRows(limit) 6558 if err == nil { 6559 return result, nil 6560 } 6561 if !isRepeatableError(err) { 6562 return result, err 6563 } 6564 tries++ 6565 if tries >= 3 { 6566 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6567 return result, err 6568 } 6569 } 6570 6571} 6572 6573func (s *RetryLayerReactionStore) GetForPost(postID string, allowFromCache bool) ([]*model.Reaction, error) { 6574 6575 tries := 0 6576 for { 6577 result, err := s.ReactionStore.GetForPost(postID, allowFromCache) 6578 if err == nil { 6579 return result, nil 6580 } 6581 if !isRepeatableError(err) { 6582 return result, err 6583 } 6584 tries++ 6585 if tries >= 3 { 6586 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6587 return result, err 6588 } 6589 } 6590 6591} 6592 6593func (s *RetryLayerReactionStore) GetForPostSince(postId string, since int64, excludeRemoteId string, inclDeleted bool) ([]*model.Reaction, error) { 6594 6595 tries := 0 6596 for { 6597 result, err := s.ReactionStore.GetForPostSince(postId, since, excludeRemoteId, inclDeleted) 6598 if err == nil { 6599 return result, nil 6600 } 6601 if !isRepeatableError(err) { 6602 return result, err 6603 } 6604 tries++ 6605 if tries >= 3 { 6606 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6607 return result, err 6608 } 6609 } 6610 6611} 6612 6613func (s *RetryLayerReactionStore) PermanentDeleteBatch(endTime int64, limit int64) (int64, error) { 6614 6615 tries := 0 6616 for { 6617 result, err := s.ReactionStore.PermanentDeleteBatch(endTime, limit) 6618 if err == nil { 6619 return result, nil 6620 } 6621 if !isRepeatableError(err) { 6622 return result, err 6623 } 6624 tries++ 6625 if tries >= 3 { 6626 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6627 return result, err 6628 } 6629 } 6630 6631} 6632 6633func (s *RetryLayerReactionStore) Save(reaction *model.Reaction) (*model.Reaction, error) { 6634 6635 tries := 0 6636 for { 6637 result, err := s.ReactionStore.Save(reaction) 6638 if err == nil { 6639 return result, nil 6640 } 6641 if !isRepeatableError(err) { 6642 return result, err 6643 } 6644 tries++ 6645 if tries >= 3 { 6646 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6647 return result, err 6648 } 6649 } 6650 6651} 6652 6653func (s *RetryLayerRemoteClusterStore) Delete(remoteClusterId string) (bool, error) { 6654 6655 tries := 0 6656 for { 6657 result, err := s.RemoteClusterStore.Delete(remoteClusterId) 6658 if err == nil { 6659 return result, nil 6660 } 6661 if !isRepeatableError(err) { 6662 return result, err 6663 } 6664 tries++ 6665 if tries >= 3 { 6666 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6667 return result, err 6668 } 6669 } 6670 6671} 6672 6673func (s *RetryLayerRemoteClusterStore) Get(remoteClusterId string) (*model.RemoteCluster, error) { 6674 6675 tries := 0 6676 for { 6677 result, err := s.RemoteClusterStore.Get(remoteClusterId) 6678 if err == nil { 6679 return result, nil 6680 } 6681 if !isRepeatableError(err) { 6682 return result, err 6683 } 6684 tries++ 6685 if tries >= 3 { 6686 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6687 return result, err 6688 } 6689 } 6690 6691} 6692 6693func (s *RetryLayerRemoteClusterStore) GetAll(filter model.RemoteClusterQueryFilter) ([]*model.RemoteCluster, error) { 6694 6695 tries := 0 6696 for { 6697 result, err := s.RemoteClusterStore.GetAll(filter) 6698 if err == nil { 6699 return result, nil 6700 } 6701 if !isRepeatableError(err) { 6702 return result, err 6703 } 6704 tries++ 6705 if tries >= 3 { 6706 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6707 return result, err 6708 } 6709 } 6710 6711} 6712 6713func (s *RetryLayerRemoteClusterStore) Save(rc *model.RemoteCluster) (*model.RemoteCluster, error) { 6714 6715 tries := 0 6716 for { 6717 result, err := s.RemoteClusterStore.Save(rc) 6718 if err == nil { 6719 return result, nil 6720 } 6721 if !isRepeatableError(err) { 6722 return result, err 6723 } 6724 tries++ 6725 if tries >= 3 { 6726 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6727 return result, err 6728 } 6729 } 6730 6731} 6732 6733func (s *RetryLayerRemoteClusterStore) SetLastPingAt(remoteClusterId string) error { 6734 6735 tries := 0 6736 for { 6737 err := s.RemoteClusterStore.SetLastPingAt(remoteClusterId) 6738 if err == nil { 6739 return nil 6740 } 6741 if !isRepeatableError(err) { 6742 return err 6743 } 6744 tries++ 6745 if tries >= 3 { 6746 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6747 return err 6748 } 6749 } 6750 6751} 6752 6753func (s *RetryLayerRemoteClusterStore) Update(rc *model.RemoteCluster) (*model.RemoteCluster, error) { 6754 6755 tries := 0 6756 for { 6757 result, err := s.RemoteClusterStore.Update(rc) 6758 if err == nil { 6759 return result, nil 6760 } 6761 if !isRepeatableError(err) { 6762 return result, err 6763 } 6764 tries++ 6765 if tries >= 3 { 6766 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6767 return result, err 6768 } 6769 } 6770 6771} 6772 6773func (s *RetryLayerRemoteClusterStore) UpdateTopics(remoteClusterId string, topics string) (*model.RemoteCluster, error) { 6774 6775 tries := 0 6776 for { 6777 result, err := s.RemoteClusterStore.UpdateTopics(remoteClusterId, topics) 6778 if err == nil { 6779 return result, nil 6780 } 6781 if !isRepeatableError(err) { 6782 return result, err 6783 } 6784 tries++ 6785 if tries >= 3 { 6786 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6787 return result, err 6788 } 6789 } 6790 6791} 6792 6793func (s *RetryLayerRetentionPolicyStore) AddChannels(policyId string, channelIds []string) error { 6794 6795 tries := 0 6796 for { 6797 err := s.RetentionPolicyStore.AddChannels(policyId, channelIds) 6798 if err == nil { 6799 return nil 6800 } 6801 if !isRepeatableError(err) { 6802 return err 6803 } 6804 tries++ 6805 if tries >= 3 { 6806 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6807 return err 6808 } 6809 } 6810 6811} 6812 6813func (s *RetryLayerRetentionPolicyStore) AddTeams(policyId string, teamIds []string) error { 6814 6815 tries := 0 6816 for { 6817 err := s.RetentionPolicyStore.AddTeams(policyId, teamIds) 6818 if err == nil { 6819 return nil 6820 } 6821 if !isRepeatableError(err) { 6822 return err 6823 } 6824 tries++ 6825 if tries >= 3 { 6826 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6827 return err 6828 } 6829 } 6830 6831} 6832 6833func (s *RetryLayerRetentionPolicyStore) Delete(id string) error { 6834 6835 tries := 0 6836 for { 6837 err := s.RetentionPolicyStore.Delete(id) 6838 if err == nil { 6839 return nil 6840 } 6841 if !isRepeatableError(err) { 6842 return err 6843 } 6844 tries++ 6845 if tries >= 3 { 6846 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6847 return err 6848 } 6849 } 6850 6851} 6852 6853func (s *RetryLayerRetentionPolicyStore) DeleteOrphanedRows(limit int) (int64, error) { 6854 6855 tries := 0 6856 for { 6857 result, err := s.RetentionPolicyStore.DeleteOrphanedRows(limit) 6858 if err == nil { 6859 return result, nil 6860 } 6861 if !isRepeatableError(err) { 6862 return result, err 6863 } 6864 tries++ 6865 if tries >= 3 { 6866 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6867 return result, err 6868 } 6869 } 6870 6871} 6872 6873func (s *RetryLayerRetentionPolicyStore) Get(id string) (*model.RetentionPolicyWithTeamAndChannelCounts, error) { 6874 6875 tries := 0 6876 for { 6877 result, err := s.RetentionPolicyStore.Get(id) 6878 if err == nil { 6879 return result, nil 6880 } 6881 if !isRepeatableError(err) { 6882 return result, err 6883 } 6884 tries++ 6885 if tries >= 3 { 6886 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6887 return result, err 6888 } 6889 } 6890 6891} 6892 6893func (s *RetryLayerRetentionPolicyStore) GetAll(offset int, limit int) ([]*model.RetentionPolicyWithTeamAndChannelCounts, error) { 6894 6895 tries := 0 6896 for { 6897 result, err := s.RetentionPolicyStore.GetAll(offset, limit) 6898 if err == nil { 6899 return result, nil 6900 } 6901 if !isRepeatableError(err) { 6902 return result, err 6903 } 6904 tries++ 6905 if tries >= 3 { 6906 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6907 return result, err 6908 } 6909 } 6910 6911} 6912 6913func (s *RetryLayerRetentionPolicyStore) GetChannelPoliciesCountForUser(userID string) (int64, error) { 6914 6915 tries := 0 6916 for { 6917 result, err := s.RetentionPolicyStore.GetChannelPoliciesCountForUser(userID) 6918 if err == nil { 6919 return result, nil 6920 } 6921 if !isRepeatableError(err) { 6922 return result, err 6923 } 6924 tries++ 6925 if tries >= 3 { 6926 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6927 return result, err 6928 } 6929 } 6930 6931} 6932 6933func (s *RetryLayerRetentionPolicyStore) GetChannelPoliciesForUser(userID string, offset int, limit int) ([]*model.RetentionPolicyForChannel, error) { 6934 6935 tries := 0 6936 for { 6937 result, err := s.RetentionPolicyStore.GetChannelPoliciesForUser(userID, offset, limit) 6938 if err == nil { 6939 return result, nil 6940 } 6941 if !isRepeatableError(err) { 6942 return result, err 6943 } 6944 tries++ 6945 if tries >= 3 { 6946 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6947 return result, err 6948 } 6949 } 6950 6951} 6952 6953func (s *RetryLayerRetentionPolicyStore) GetChannels(policyId string, offset int, limit int) (model.ChannelListWithTeamData, error) { 6954 6955 tries := 0 6956 for { 6957 result, err := s.RetentionPolicyStore.GetChannels(policyId, offset, limit) 6958 if err == nil { 6959 return result, nil 6960 } 6961 if !isRepeatableError(err) { 6962 return result, err 6963 } 6964 tries++ 6965 if tries >= 3 { 6966 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6967 return result, err 6968 } 6969 } 6970 6971} 6972 6973func (s *RetryLayerRetentionPolicyStore) GetChannelsCount(policyId string) (int64, error) { 6974 6975 tries := 0 6976 for { 6977 result, err := s.RetentionPolicyStore.GetChannelsCount(policyId) 6978 if err == nil { 6979 return result, nil 6980 } 6981 if !isRepeatableError(err) { 6982 return result, err 6983 } 6984 tries++ 6985 if tries >= 3 { 6986 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 6987 return result, err 6988 } 6989 } 6990 6991} 6992 6993func (s *RetryLayerRetentionPolicyStore) GetCount() (int64, error) { 6994 6995 tries := 0 6996 for { 6997 result, err := s.RetentionPolicyStore.GetCount() 6998 if err == nil { 6999 return result, nil 7000 } 7001 if !isRepeatableError(err) { 7002 return result, err 7003 } 7004 tries++ 7005 if tries >= 3 { 7006 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7007 return result, err 7008 } 7009 } 7010 7011} 7012 7013func (s *RetryLayerRetentionPolicyStore) GetTeamPoliciesCountForUser(userID string) (int64, error) { 7014 7015 tries := 0 7016 for { 7017 result, err := s.RetentionPolicyStore.GetTeamPoliciesCountForUser(userID) 7018 if err == nil { 7019 return result, nil 7020 } 7021 if !isRepeatableError(err) { 7022 return result, err 7023 } 7024 tries++ 7025 if tries >= 3 { 7026 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7027 return result, err 7028 } 7029 } 7030 7031} 7032 7033func (s *RetryLayerRetentionPolicyStore) GetTeamPoliciesForUser(userID string, offset int, limit int) ([]*model.RetentionPolicyForTeam, error) { 7034 7035 tries := 0 7036 for { 7037 result, err := s.RetentionPolicyStore.GetTeamPoliciesForUser(userID, offset, limit) 7038 if err == nil { 7039 return result, nil 7040 } 7041 if !isRepeatableError(err) { 7042 return result, err 7043 } 7044 tries++ 7045 if tries >= 3 { 7046 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7047 return result, err 7048 } 7049 } 7050 7051} 7052 7053func (s *RetryLayerRetentionPolicyStore) GetTeams(policyId string, offset int, limit int) ([]*model.Team, error) { 7054 7055 tries := 0 7056 for { 7057 result, err := s.RetentionPolicyStore.GetTeams(policyId, offset, limit) 7058 if err == nil { 7059 return result, nil 7060 } 7061 if !isRepeatableError(err) { 7062 return result, err 7063 } 7064 tries++ 7065 if tries >= 3 { 7066 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7067 return result, err 7068 } 7069 } 7070 7071} 7072 7073func (s *RetryLayerRetentionPolicyStore) GetTeamsCount(policyId string) (int64, error) { 7074 7075 tries := 0 7076 for { 7077 result, err := s.RetentionPolicyStore.GetTeamsCount(policyId) 7078 if err == nil { 7079 return result, nil 7080 } 7081 if !isRepeatableError(err) { 7082 return result, err 7083 } 7084 tries++ 7085 if tries >= 3 { 7086 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7087 return result, err 7088 } 7089 } 7090 7091} 7092 7093func (s *RetryLayerRetentionPolicyStore) Patch(patch *model.RetentionPolicyWithTeamAndChannelIDs) (*model.RetentionPolicyWithTeamAndChannelCounts, error) { 7094 7095 tries := 0 7096 for { 7097 result, err := s.RetentionPolicyStore.Patch(patch) 7098 if err == nil { 7099 return result, nil 7100 } 7101 if !isRepeatableError(err) { 7102 return result, err 7103 } 7104 tries++ 7105 if tries >= 3 { 7106 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7107 return result, err 7108 } 7109 } 7110 7111} 7112 7113func (s *RetryLayerRetentionPolicyStore) RemoveChannels(policyId string, channelIds []string) error { 7114 7115 tries := 0 7116 for { 7117 err := s.RetentionPolicyStore.RemoveChannels(policyId, channelIds) 7118 if err == nil { 7119 return nil 7120 } 7121 if !isRepeatableError(err) { 7122 return err 7123 } 7124 tries++ 7125 if tries >= 3 { 7126 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7127 return err 7128 } 7129 } 7130 7131} 7132 7133func (s *RetryLayerRetentionPolicyStore) RemoveTeams(policyId string, teamIds []string) error { 7134 7135 tries := 0 7136 for { 7137 err := s.RetentionPolicyStore.RemoveTeams(policyId, teamIds) 7138 if err == nil { 7139 return nil 7140 } 7141 if !isRepeatableError(err) { 7142 return err 7143 } 7144 tries++ 7145 if tries >= 3 { 7146 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7147 return err 7148 } 7149 } 7150 7151} 7152 7153func (s *RetryLayerRetentionPolicyStore) Save(policy *model.RetentionPolicyWithTeamAndChannelIDs) (*model.RetentionPolicyWithTeamAndChannelCounts, error) { 7154 7155 tries := 0 7156 for { 7157 result, err := s.RetentionPolicyStore.Save(policy) 7158 if err == nil { 7159 return result, nil 7160 } 7161 if !isRepeatableError(err) { 7162 return result, err 7163 } 7164 tries++ 7165 if tries >= 3 { 7166 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7167 return result, err 7168 } 7169 } 7170 7171} 7172 7173func (s *RetryLayerRoleStore) AllChannelSchemeRoles() ([]*model.Role, error) { 7174 7175 tries := 0 7176 for { 7177 result, err := s.RoleStore.AllChannelSchemeRoles() 7178 if err == nil { 7179 return result, nil 7180 } 7181 if !isRepeatableError(err) { 7182 return result, err 7183 } 7184 tries++ 7185 if tries >= 3 { 7186 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7187 return result, err 7188 } 7189 } 7190 7191} 7192 7193func (s *RetryLayerRoleStore) ChannelHigherScopedPermissions(roleNames []string) (map[string]*model.RolePermissions, error) { 7194 7195 tries := 0 7196 for { 7197 result, err := s.RoleStore.ChannelHigherScopedPermissions(roleNames) 7198 if err == nil { 7199 return result, nil 7200 } 7201 if !isRepeatableError(err) { 7202 return result, err 7203 } 7204 tries++ 7205 if tries >= 3 { 7206 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7207 return result, err 7208 } 7209 } 7210 7211} 7212 7213func (s *RetryLayerRoleStore) ChannelRolesUnderTeamRole(roleName string) ([]*model.Role, error) { 7214 7215 tries := 0 7216 for { 7217 result, err := s.RoleStore.ChannelRolesUnderTeamRole(roleName) 7218 if err == nil { 7219 return result, nil 7220 } 7221 if !isRepeatableError(err) { 7222 return result, err 7223 } 7224 tries++ 7225 if tries >= 3 { 7226 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7227 return result, err 7228 } 7229 } 7230 7231} 7232 7233func (s *RetryLayerRoleStore) Delete(roleID string) (*model.Role, error) { 7234 7235 tries := 0 7236 for { 7237 result, err := s.RoleStore.Delete(roleID) 7238 if err == nil { 7239 return result, nil 7240 } 7241 if !isRepeatableError(err) { 7242 return result, err 7243 } 7244 tries++ 7245 if tries >= 3 { 7246 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7247 return result, err 7248 } 7249 } 7250 7251} 7252 7253func (s *RetryLayerRoleStore) Get(roleID string) (*model.Role, error) { 7254 7255 tries := 0 7256 for { 7257 result, err := s.RoleStore.Get(roleID) 7258 if err == nil { 7259 return result, nil 7260 } 7261 if !isRepeatableError(err) { 7262 return result, err 7263 } 7264 tries++ 7265 if tries >= 3 { 7266 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7267 return result, err 7268 } 7269 } 7270 7271} 7272 7273func (s *RetryLayerRoleStore) GetAll() ([]*model.Role, error) { 7274 7275 tries := 0 7276 for { 7277 result, err := s.RoleStore.GetAll() 7278 if err == nil { 7279 return result, nil 7280 } 7281 if !isRepeatableError(err) { 7282 return result, err 7283 } 7284 tries++ 7285 if tries >= 3 { 7286 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7287 return result, err 7288 } 7289 } 7290 7291} 7292 7293func (s *RetryLayerRoleStore) GetByName(ctx context.Context, name string) (*model.Role, error) { 7294 7295 tries := 0 7296 for { 7297 result, err := s.RoleStore.GetByName(ctx, name) 7298 if err == nil { 7299 return result, nil 7300 } 7301 if !isRepeatableError(err) { 7302 return result, err 7303 } 7304 tries++ 7305 if tries >= 3 { 7306 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7307 return result, err 7308 } 7309 } 7310 7311} 7312 7313func (s *RetryLayerRoleStore) GetByNames(names []string) ([]*model.Role, error) { 7314 7315 tries := 0 7316 for { 7317 result, err := s.RoleStore.GetByNames(names) 7318 if err == nil { 7319 return result, nil 7320 } 7321 if !isRepeatableError(err) { 7322 return result, err 7323 } 7324 tries++ 7325 if tries >= 3 { 7326 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7327 return result, err 7328 } 7329 } 7330 7331} 7332 7333func (s *RetryLayerRoleStore) PermanentDeleteAll() error { 7334 7335 tries := 0 7336 for { 7337 err := s.RoleStore.PermanentDeleteAll() 7338 if err == nil { 7339 return nil 7340 } 7341 if !isRepeatableError(err) { 7342 return err 7343 } 7344 tries++ 7345 if tries >= 3 { 7346 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7347 return err 7348 } 7349 } 7350 7351} 7352 7353func (s *RetryLayerRoleStore) Save(role *model.Role) (*model.Role, error) { 7354 7355 tries := 0 7356 for { 7357 result, err := s.RoleStore.Save(role) 7358 if err == nil { 7359 return result, nil 7360 } 7361 if !isRepeatableError(err) { 7362 return result, err 7363 } 7364 tries++ 7365 if tries >= 3 { 7366 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7367 return result, err 7368 } 7369 } 7370 7371} 7372 7373func (s *RetryLayerSchemeStore) CountByScope(scope string) (int64, error) { 7374 7375 tries := 0 7376 for { 7377 result, err := s.SchemeStore.CountByScope(scope) 7378 if err == nil { 7379 return result, nil 7380 } 7381 if !isRepeatableError(err) { 7382 return result, err 7383 } 7384 tries++ 7385 if tries >= 3 { 7386 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7387 return result, err 7388 } 7389 } 7390 7391} 7392 7393func (s *RetryLayerSchemeStore) CountWithoutPermission(scope string, permissionID string, roleScope model.RoleScope, roleType model.RoleType) (int64, error) { 7394 7395 tries := 0 7396 for { 7397 result, err := s.SchemeStore.CountWithoutPermission(scope, permissionID, roleScope, roleType) 7398 if err == nil { 7399 return result, nil 7400 } 7401 if !isRepeatableError(err) { 7402 return result, err 7403 } 7404 tries++ 7405 if tries >= 3 { 7406 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7407 return result, err 7408 } 7409 } 7410 7411} 7412 7413func (s *RetryLayerSchemeStore) Delete(schemeID string) (*model.Scheme, error) { 7414 7415 tries := 0 7416 for { 7417 result, err := s.SchemeStore.Delete(schemeID) 7418 if err == nil { 7419 return result, nil 7420 } 7421 if !isRepeatableError(err) { 7422 return result, err 7423 } 7424 tries++ 7425 if tries >= 3 { 7426 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7427 return result, err 7428 } 7429 } 7430 7431} 7432 7433func (s *RetryLayerSchemeStore) Get(schemeID string) (*model.Scheme, error) { 7434 7435 tries := 0 7436 for { 7437 result, err := s.SchemeStore.Get(schemeID) 7438 if err == nil { 7439 return result, nil 7440 } 7441 if !isRepeatableError(err) { 7442 return result, err 7443 } 7444 tries++ 7445 if tries >= 3 { 7446 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7447 return result, err 7448 } 7449 } 7450 7451} 7452 7453func (s *RetryLayerSchemeStore) GetAllPage(scope string, offset int, limit int) ([]*model.Scheme, error) { 7454 7455 tries := 0 7456 for { 7457 result, err := s.SchemeStore.GetAllPage(scope, offset, limit) 7458 if err == nil { 7459 return result, nil 7460 } 7461 if !isRepeatableError(err) { 7462 return result, err 7463 } 7464 tries++ 7465 if tries >= 3 { 7466 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7467 return result, err 7468 } 7469 } 7470 7471} 7472 7473func (s *RetryLayerSchemeStore) GetByName(schemeName string) (*model.Scheme, error) { 7474 7475 tries := 0 7476 for { 7477 result, err := s.SchemeStore.GetByName(schemeName) 7478 if err == nil { 7479 return result, nil 7480 } 7481 if !isRepeatableError(err) { 7482 return result, err 7483 } 7484 tries++ 7485 if tries >= 3 { 7486 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7487 return result, err 7488 } 7489 } 7490 7491} 7492 7493func (s *RetryLayerSchemeStore) PermanentDeleteAll() error { 7494 7495 tries := 0 7496 for { 7497 err := s.SchemeStore.PermanentDeleteAll() 7498 if err == nil { 7499 return nil 7500 } 7501 if !isRepeatableError(err) { 7502 return err 7503 } 7504 tries++ 7505 if tries >= 3 { 7506 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7507 return err 7508 } 7509 } 7510 7511} 7512 7513func (s *RetryLayerSchemeStore) Save(scheme *model.Scheme) (*model.Scheme, error) { 7514 7515 tries := 0 7516 for { 7517 result, err := s.SchemeStore.Save(scheme) 7518 if err == nil { 7519 return result, nil 7520 } 7521 if !isRepeatableError(err) { 7522 return result, err 7523 } 7524 tries++ 7525 if tries >= 3 { 7526 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7527 return result, err 7528 } 7529 } 7530 7531} 7532 7533func (s *RetryLayerSessionStore) AnalyticsSessionCount() (int64, error) { 7534 7535 tries := 0 7536 for { 7537 result, err := s.SessionStore.AnalyticsSessionCount() 7538 if err == nil { 7539 return result, nil 7540 } 7541 if !isRepeatableError(err) { 7542 return result, err 7543 } 7544 tries++ 7545 if tries >= 3 { 7546 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7547 return result, err 7548 } 7549 } 7550 7551} 7552 7553func (s *RetryLayerSessionStore) Cleanup(expiryTime int64, batchSize int64) error { 7554 7555 tries := 0 7556 for { 7557 err := s.SessionStore.Cleanup(expiryTime, batchSize) 7558 if err == nil { 7559 return nil 7560 } 7561 if !isRepeatableError(err) { 7562 return err 7563 } 7564 tries++ 7565 if tries >= 3 { 7566 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7567 return err 7568 } 7569 } 7570 7571} 7572 7573func (s *RetryLayerSessionStore) Get(ctx context.Context, sessionIDOrToken string) (*model.Session, error) { 7574 7575 tries := 0 7576 for { 7577 result, err := s.SessionStore.Get(ctx, sessionIDOrToken) 7578 if err == nil { 7579 return result, nil 7580 } 7581 if !isRepeatableError(err) { 7582 return result, err 7583 } 7584 tries++ 7585 if tries >= 3 { 7586 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7587 return result, err 7588 } 7589 } 7590 7591} 7592 7593func (s *RetryLayerSessionStore) GetSessions(userID string) ([]*model.Session, error) { 7594 7595 tries := 0 7596 for { 7597 result, err := s.SessionStore.GetSessions(userID) 7598 if err == nil { 7599 return result, nil 7600 } 7601 if !isRepeatableError(err) { 7602 return result, err 7603 } 7604 tries++ 7605 if tries >= 3 { 7606 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7607 return result, err 7608 } 7609 } 7610 7611} 7612 7613func (s *RetryLayerSessionStore) GetSessionsExpired(thresholdMillis int64, mobileOnly bool, unnotifiedOnly bool) ([]*model.Session, error) { 7614 7615 tries := 0 7616 for { 7617 result, err := s.SessionStore.GetSessionsExpired(thresholdMillis, mobileOnly, unnotifiedOnly) 7618 if err == nil { 7619 return result, nil 7620 } 7621 if !isRepeatableError(err) { 7622 return result, err 7623 } 7624 tries++ 7625 if tries >= 3 { 7626 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7627 return result, err 7628 } 7629 } 7630 7631} 7632 7633func (s *RetryLayerSessionStore) GetSessionsWithActiveDeviceIds(userID string) ([]*model.Session, error) { 7634 7635 tries := 0 7636 for { 7637 result, err := s.SessionStore.GetSessionsWithActiveDeviceIds(userID) 7638 if err == nil { 7639 return result, nil 7640 } 7641 if !isRepeatableError(err) { 7642 return result, err 7643 } 7644 tries++ 7645 if tries >= 3 { 7646 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7647 return result, err 7648 } 7649 } 7650 7651} 7652 7653func (s *RetryLayerSessionStore) PermanentDeleteSessionsByUser(teamID string) error { 7654 7655 tries := 0 7656 for { 7657 err := s.SessionStore.PermanentDeleteSessionsByUser(teamID) 7658 if err == nil { 7659 return nil 7660 } 7661 if !isRepeatableError(err) { 7662 return err 7663 } 7664 tries++ 7665 if tries >= 3 { 7666 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7667 return err 7668 } 7669 } 7670 7671} 7672 7673func (s *RetryLayerSessionStore) Remove(sessionIDOrToken string) error { 7674 7675 tries := 0 7676 for { 7677 err := s.SessionStore.Remove(sessionIDOrToken) 7678 if err == nil { 7679 return nil 7680 } 7681 if !isRepeatableError(err) { 7682 return err 7683 } 7684 tries++ 7685 if tries >= 3 { 7686 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7687 return err 7688 } 7689 } 7690 7691} 7692 7693func (s *RetryLayerSessionStore) RemoveAllSessions() error { 7694 7695 tries := 0 7696 for { 7697 err := s.SessionStore.RemoveAllSessions() 7698 if err == nil { 7699 return nil 7700 } 7701 if !isRepeatableError(err) { 7702 return err 7703 } 7704 tries++ 7705 if tries >= 3 { 7706 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7707 return err 7708 } 7709 } 7710 7711} 7712 7713func (s *RetryLayerSessionStore) Save(session *model.Session) (*model.Session, error) { 7714 7715 tries := 0 7716 for { 7717 result, err := s.SessionStore.Save(session) 7718 if err == nil { 7719 return result, nil 7720 } 7721 if !isRepeatableError(err) { 7722 return result, err 7723 } 7724 tries++ 7725 if tries >= 3 { 7726 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7727 return result, err 7728 } 7729 } 7730 7731} 7732 7733func (s *RetryLayerSessionStore) UpdateDeviceId(id string, deviceID string, expiresAt int64) (string, error) { 7734 7735 tries := 0 7736 for { 7737 result, err := s.SessionStore.UpdateDeviceId(id, deviceID, expiresAt) 7738 if err == nil { 7739 return result, nil 7740 } 7741 if !isRepeatableError(err) { 7742 return result, err 7743 } 7744 tries++ 7745 if tries >= 3 { 7746 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7747 return result, err 7748 } 7749 } 7750 7751} 7752 7753func (s *RetryLayerSessionStore) UpdateExpiredNotify(sessionid string, notified bool) error { 7754 7755 tries := 0 7756 for { 7757 err := s.SessionStore.UpdateExpiredNotify(sessionid, notified) 7758 if err == nil { 7759 return nil 7760 } 7761 if !isRepeatableError(err) { 7762 return err 7763 } 7764 tries++ 7765 if tries >= 3 { 7766 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7767 return err 7768 } 7769 } 7770 7771} 7772 7773func (s *RetryLayerSessionStore) UpdateExpiresAt(sessionID string, time int64) error { 7774 7775 tries := 0 7776 for { 7777 err := s.SessionStore.UpdateExpiresAt(sessionID, time) 7778 if err == nil { 7779 return nil 7780 } 7781 if !isRepeatableError(err) { 7782 return err 7783 } 7784 tries++ 7785 if tries >= 3 { 7786 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7787 return err 7788 } 7789 } 7790 7791} 7792 7793func (s *RetryLayerSessionStore) UpdateLastActivityAt(sessionID string, time int64) error { 7794 7795 tries := 0 7796 for { 7797 err := s.SessionStore.UpdateLastActivityAt(sessionID, time) 7798 if err == nil { 7799 return nil 7800 } 7801 if !isRepeatableError(err) { 7802 return err 7803 } 7804 tries++ 7805 if tries >= 3 { 7806 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7807 return err 7808 } 7809 } 7810 7811} 7812 7813func (s *RetryLayerSessionStore) UpdateProps(session *model.Session) error { 7814 7815 tries := 0 7816 for { 7817 err := s.SessionStore.UpdateProps(session) 7818 if err == nil { 7819 return nil 7820 } 7821 if !isRepeatableError(err) { 7822 return err 7823 } 7824 tries++ 7825 if tries >= 3 { 7826 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7827 return err 7828 } 7829 } 7830 7831} 7832 7833func (s *RetryLayerSessionStore) UpdateRoles(userID string, roles string) (string, error) { 7834 7835 tries := 0 7836 for { 7837 result, err := s.SessionStore.UpdateRoles(userID, roles) 7838 if err == nil { 7839 return result, nil 7840 } 7841 if !isRepeatableError(err) { 7842 return result, err 7843 } 7844 tries++ 7845 if tries >= 3 { 7846 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7847 return result, err 7848 } 7849 } 7850 7851} 7852 7853func (s *RetryLayerSharedChannelStore) Delete(channelId string) (bool, error) { 7854 7855 tries := 0 7856 for { 7857 result, err := s.SharedChannelStore.Delete(channelId) 7858 if err == nil { 7859 return result, nil 7860 } 7861 if !isRepeatableError(err) { 7862 return result, err 7863 } 7864 tries++ 7865 if tries >= 3 { 7866 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7867 return result, err 7868 } 7869 } 7870 7871} 7872 7873func (s *RetryLayerSharedChannelStore) DeleteRemote(remoteId string) (bool, error) { 7874 7875 tries := 0 7876 for { 7877 result, err := s.SharedChannelStore.DeleteRemote(remoteId) 7878 if err == nil { 7879 return result, nil 7880 } 7881 if !isRepeatableError(err) { 7882 return result, err 7883 } 7884 tries++ 7885 if tries >= 3 { 7886 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7887 return result, err 7888 } 7889 } 7890 7891} 7892 7893func (s *RetryLayerSharedChannelStore) Get(channelId string) (*model.SharedChannel, error) { 7894 7895 tries := 0 7896 for { 7897 result, err := s.SharedChannelStore.Get(channelId) 7898 if err == nil { 7899 return result, nil 7900 } 7901 if !isRepeatableError(err) { 7902 return result, err 7903 } 7904 tries++ 7905 if tries >= 3 { 7906 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7907 return result, err 7908 } 7909 } 7910 7911} 7912 7913func (s *RetryLayerSharedChannelStore) GetAll(offset int, limit int, opts model.SharedChannelFilterOpts) ([]*model.SharedChannel, error) { 7914 7915 tries := 0 7916 for { 7917 result, err := s.SharedChannelStore.GetAll(offset, limit, opts) 7918 if err == nil { 7919 return result, nil 7920 } 7921 if !isRepeatableError(err) { 7922 return result, err 7923 } 7924 tries++ 7925 if tries >= 3 { 7926 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7927 return result, err 7928 } 7929 } 7930 7931} 7932 7933func (s *RetryLayerSharedChannelStore) GetAllCount(opts model.SharedChannelFilterOpts) (int64, error) { 7934 7935 tries := 0 7936 for { 7937 result, err := s.SharedChannelStore.GetAllCount(opts) 7938 if err == nil { 7939 return result, nil 7940 } 7941 if !isRepeatableError(err) { 7942 return result, err 7943 } 7944 tries++ 7945 if tries >= 3 { 7946 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7947 return result, err 7948 } 7949 } 7950 7951} 7952 7953func (s *RetryLayerSharedChannelStore) GetAttachment(fileId string, remoteId string) (*model.SharedChannelAttachment, error) { 7954 7955 tries := 0 7956 for { 7957 result, err := s.SharedChannelStore.GetAttachment(fileId, remoteId) 7958 if err == nil { 7959 return result, nil 7960 } 7961 if !isRepeatableError(err) { 7962 return result, err 7963 } 7964 tries++ 7965 if tries >= 3 { 7966 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7967 return result, err 7968 } 7969 } 7970 7971} 7972 7973func (s *RetryLayerSharedChannelStore) GetRemote(id string) (*model.SharedChannelRemote, error) { 7974 7975 tries := 0 7976 for { 7977 result, err := s.SharedChannelStore.GetRemote(id) 7978 if err == nil { 7979 return result, nil 7980 } 7981 if !isRepeatableError(err) { 7982 return result, err 7983 } 7984 tries++ 7985 if tries >= 3 { 7986 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 7987 return result, err 7988 } 7989 } 7990 7991} 7992 7993func (s *RetryLayerSharedChannelStore) GetRemoteByIds(channelId string, remoteId string) (*model.SharedChannelRemote, error) { 7994 7995 tries := 0 7996 for { 7997 result, err := s.SharedChannelStore.GetRemoteByIds(channelId, remoteId) 7998 if err == nil { 7999 return result, nil 8000 } 8001 if !isRepeatableError(err) { 8002 return result, err 8003 } 8004 tries++ 8005 if tries >= 3 { 8006 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8007 return result, err 8008 } 8009 } 8010 8011} 8012 8013func (s *RetryLayerSharedChannelStore) GetRemoteForUser(remoteId string, userId string) (*model.RemoteCluster, error) { 8014 8015 tries := 0 8016 for { 8017 result, err := s.SharedChannelStore.GetRemoteForUser(remoteId, userId) 8018 if err == nil { 8019 return result, nil 8020 } 8021 if !isRepeatableError(err) { 8022 return result, err 8023 } 8024 tries++ 8025 if tries >= 3 { 8026 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8027 return result, err 8028 } 8029 } 8030 8031} 8032 8033func (s *RetryLayerSharedChannelStore) GetRemotes(opts model.SharedChannelRemoteFilterOpts) ([]*model.SharedChannelRemote, error) { 8034 8035 tries := 0 8036 for { 8037 result, err := s.SharedChannelStore.GetRemotes(opts) 8038 if err == nil { 8039 return result, nil 8040 } 8041 if !isRepeatableError(err) { 8042 return result, err 8043 } 8044 tries++ 8045 if tries >= 3 { 8046 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8047 return result, err 8048 } 8049 } 8050 8051} 8052 8053func (s *RetryLayerSharedChannelStore) GetRemotesStatus(channelId string) ([]*model.SharedChannelRemoteStatus, error) { 8054 8055 tries := 0 8056 for { 8057 result, err := s.SharedChannelStore.GetRemotesStatus(channelId) 8058 if err == nil { 8059 return result, nil 8060 } 8061 if !isRepeatableError(err) { 8062 return result, err 8063 } 8064 tries++ 8065 if tries >= 3 { 8066 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8067 return result, err 8068 } 8069 } 8070 8071} 8072 8073func (s *RetryLayerSharedChannelStore) GetSingleUser(userID string, channelID string, remoteID string) (*model.SharedChannelUser, error) { 8074 8075 tries := 0 8076 for { 8077 result, err := s.SharedChannelStore.GetSingleUser(userID, channelID, remoteID) 8078 if err == nil { 8079 return result, nil 8080 } 8081 if !isRepeatableError(err) { 8082 return result, err 8083 } 8084 tries++ 8085 if tries >= 3 { 8086 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8087 return result, err 8088 } 8089 } 8090 8091} 8092 8093func (s *RetryLayerSharedChannelStore) GetUsersForSync(filter model.GetUsersForSyncFilter) ([]*model.User, error) { 8094 8095 tries := 0 8096 for { 8097 result, err := s.SharedChannelStore.GetUsersForSync(filter) 8098 if err == nil { 8099 return result, nil 8100 } 8101 if !isRepeatableError(err) { 8102 return result, err 8103 } 8104 tries++ 8105 if tries >= 3 { 8106 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8107 return result, err 8108 } 8109 } 8110 8111} 8112 8113func (s *RetryLayerSharedChannelStore) GetUsersForUser(userID string) ([]*model.SharedChannelUser, error) { 8114 8115 tries := 0 8116 for { 8117 result, err := s.SharedChannelStore.GetUsersForUser(userID) 8118 if err == nil { 8119 return result, nil 8120 } 8121 if !isRepeatableError(err) { 8122 return result, err 8123 } 8124 tries++ 8125 if tries >= 3 { 8126 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8127 return result, err 8128 } 8129 } 8130 8131} 8132 8133func (s *RetryLayerSharedChannelStore) HasChannel(channelID string) (bool, error) { 8134 8135 tries := 0 8136 for { 8137 result, err := s.SharedChannelStore.HasChannel(channelID) 8138 if err == nil { 8139 return result, nil 8140 } 8141 if !isRepeatableError(err) { 8142 return result, err 8143 } 8144 tries++ 8145 if tries >= 3 { 8146 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8147 return result, err 8148 } 8149 } 8150 8151} 8152 8153func (s *RetryLayerSharedChannelStore) HasRemote(channelID string, remoteId string) (bool, error) { 8154 8155 tries := 0 8156 for { 8157 result, err := s.SharedChannelStore.HasRemote(channelID, remoteId) 8158 if err == nil { 8159 return result, nil 8160 } 8161 if !isRepeatableError(err) { 8162 return result, err 8163 } 8164 tries++ 8165 if tries >= 3 { 8166 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8167 return result, err 8168 } 8169 } 8170 8171} 8172 8173func (s *RetryLayerSharedChannelStore) Save(sc *model.SharedChannel) (*model.SharedChannel, error) { 8174 8175 tries := 0 8176 for { 8177 result, err := s.SharedChannelStore.Save(sc) 8178 if err == nil { 8179 return result, nil 8180 } 8181 if !isRepeatableError(err) { 8182 return result, err 8183 } 8184 tries++ 8185 if tries >= 3 { 8186 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8187 return result, err 8188 } 8189 } 8190 8191} 8192 8193func (s *RetryLayerSharedChannelStore) SaveAttachment(remote *model.SharedChannelAttachment) (*model.SharedChannelAttachment, error) { 8194 8195 tries := 0 8196 for { 8197 result, err := s.SharedChannelStore.SaveAttachment(remote) 8198 if err == nil { 8199 return result, nil 8200 } 8201 if !isRepeatableError(err) { 8202 return result, err 8203 } 8204 tries++ 8205 if tries >= 3 { 8206 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8207 return result, err 8208 } 8209 } 8210 8211} 8212 8213func (s *RetryLayerSharedChannelStore) SaveRemote(remote *model.SharedChannelRemote) (*model.SharedChannelRemote, error) { 8214 8215 tries := 0 8216 for { 8217 result, err := s.SharedChannelStore.SaveRemote(remote) 8218 if err == nil { 8219 return result, nil 8220 } 8221 if !isRepeatableError(err) { 8222 return result, err 8223 } 8224 tries++ 8225 if tries >= 3 { 8226 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8227 return result, err 8228 } 8229 } 8230 8231} 8232 8233func (s *RetryLayerSharedChannelStore) SaveUser(remote *model.SharedChannelUser) (*model.SharedChannelUser, error) { 8234 8235 tries := 0 8236 for { 8237 result, err := s.SharedChannelStore.SaveUser(remote) 8238 if err == nil { 8239 return result, nil 8240 } 8241 if !isRepeatableError(err) { 8242 return result, err 8243 } 8244 tries++ 8245 if tries >= 3 { 8246 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8247 return result, err 8248 } 8249 } 8250 8251} 8252 8253func (s *RetryLayerSharedChannelStore) Update(sc *model.SharedChannel) (*model.SharedChannel, error) { 8254 8255 tries := 0 8256 for { 8257 result, err := s.SharedChannelStore.Update(sc) 8258 if err == nil { 8259 return result, nil 8260 } 8261 if !isRepeatableError(err) { 8262 return result, err 8263 } 8264 tries++ 8265 if tries >= 3 { 8266 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8267 return result, err 8268 } 8269 } 8270 8271} 8272 8273func (s *RetryLayerSharedChannelStore) UpdateAttachmentLastSyncAt(id string, syncTime int64) error { 8274 8275 tries := 0 8276 for { 8277 err := s.SharedChannelStore.UpdateAttachmentLastSyncAt(id, syncTime) 8278 if err == nil { 8279 return nil 8280 } 8281 if !isRepeatableError(err) { 8282 return err 8283 } 8284 tries++ 8285 if tries >= 3 { 8286 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8287 return err 8288 } 8289 } 8290 8291} 8292 8293func (s *RetryLayerSharedChannelStore) UpdateRemote(remote *model.SharedChannelRemote) (*model.SharedChannelRemote, error) { 8294 8295 tries := 0 8296 for { 8297 result, err := s.SharedChannelStore.UpdateRemote(remote) 8298 if err == nil { 8299 return result, nil 8300 } 8301 if !isRepeatableError(err) { 8302 return result, err 8303 } 8304 tries++ 8305 if tries >= 3 { 8306 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8307 return result, err 8308 } 8309 } 8310 8311} 8312 8313func (s *RetryLayerSharedChannelStore) UpdateRemoteCursor(id string, cursor model.GetPostsSinceForSyncCursor) error { 8314 8315 tries := 0 8316 for { 8317 err := s.SharedChannelStore.UpdateRemoteCursor(id, cursor) 8318 if err == nil { 8319 return nil 8320 } 8321 if !isRepeatableError(err) { 8322 return err 8323 } 8324 tries++ 8325 if tries >= 3 { 8326 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8327 return err 8328 } 8329 } 8330 8331} 8332 8333func (s *RetryLayerSharedChannelStore) UpdateUserLastSyncAt(userID string, channelID string, remoteID string) error { 8334 8335 tries := 0 8336 for { 8337 err := s.SharedChannelStore.UpdateUserLastSyncAt(userID, channelID, remoteID) 8338 if err == nil { 8339 return nil 8340 } 8341 if !isRepeatableError(err) { 8342 return err 8343 } 8344 tries++ 8345 if tries >= 3 { 8346 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8347 return err 8348 } 8349 } 8350 8351} 8352 8353func (s *RetryLayerSharedChannelStore) UpsertAttachment(remote *model.SharedChannelAttachment) (string, error) { 8354 8355 tries := 0 8356 for { 8357 result, err := s.SharedChannelStore.UpsertAttachment(remote) 8358 if err == nil { 8359 return result, nil 8360 } 8361 if !isRepeatableError(err) { 8362 return result, err 8363 } 8364 tries++ 8365 if tries >= 3 { 8366 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8367 return result, err 8368 } 8369 } 8370 8371} 8372 8373func (s *RetryLayerStatusStore) Get(userID string) (*model.Status, error) { 8374 8375 tries := 0 8376 for { 8377 result, err := s.StatusStore.Get(userID) 8378 if err == nil { 8379 return result, nil 8380 } 8381 if !isRepeatableError(err) { 8382 return result, err 8383 } 8384 tries++ 8385 if tries >= 3 { 8386 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8387 return result, err 8388 } 8389 } 8390 8391} 8392 8393func (s *RetryLayerStatusStore) GetByIds(userIds []string) ([]*model.Status, error) { 8394 8395 tries := 0 8396 for { 8397 result, err := s.StatusStore.GetByIds(userIds) 8398 if err == nil { 8399 return result, nil 8400 } 8401 if !isRepeatableError(err) { 8402 return result, err 8403 } 8404 tries++ 8405 if tries >= 3 { 8406 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8407 return result, err 8408 } 8409 } 8410 8411} 8412 8413func (s *RetryLayerStatusStore) GetTotalActiveUsersCount() (int64, error) { 8414 8415 tries := 0 8416 for { 8417 result, err := s.StatusStore.GetTotalActiveUsersCount() 8418 if err == nil { 8419 return result, nil 8420 } 8421 if !isRepeatableError(err) { 8422 return result, err 8423 } 8424 tries++ 8425 if tries >= 3 { 8426 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8427 return result, err 8428 } 8429 } 8430 8431} 8432 8433func (s *RetryLayerStatusStore) ResetAll() error { 8434 8435 tries := 0 8436 for { 8437 err := s.StatusStore.ResetAll() 8438 if err == nil { 8439 return nil 8440 } 8441 if !isRepeatableError(err) { 8442 return err 8443 } 8444 tries++ 8445 if tries >= 3 { 8446 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8447 return err 8448 } 8449 } 8450 8451} 8452 8453func (s *RetryLayerStatusStore) SaveOrUpdate(status *model.Status) error { 8454 8455 tries := 0 8456 for { 8457 err := s.StatusStore.SaveOrUpdate(status) 8458 if err == nil { 8459 return nil 8460 } 8461 if !isRepeatableError(err) { 8462 return err 8463 } 8464 tries++ 8465 if tries >= 3 { 8466 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8467 return err 8468 } 8469 } 8470 8471} 8472 8473func (s *RetryLayerStatusStore) UpdateExpiredDNDStatuses() ([]*model.Status, error) { 8474 8475 tries := 0 8476 for { 8477 result, err := s.StatusStore.UpdateExpiredDNDStatuses() 8478 if err == nil { 8479 return result, nil 8480 } 8481 if !isRepeatableError(err) { 8482 return result, err 8483 } 8484 tries++ 8485 if tries >= 3 { 8486 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8487 return result, err 8488 } 8489 } 8490 8491} 8492 8493func (s *RetryLayerStatusStore) UpdateLastActivityAt(userID string, lastActivityAt int64) error { 8494 8495 tries := 0 8496 for { 8497 err := s.StatusStore.UpdateLastActivityAt(userID, lastActivityAt) 8498 if err == nil { 8499 return nil 8500 } 8501 if !isRepeatableError(err) { 8502 return err 8503 } 8504 tries++ 8505 if tries >= 3 { 8506 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8507 return err 8508 } 8509 } 8510 8511} 8512 8513func (s *RetryLayerSystemStore) Get() (model.StringMap, error) { 8514 8515 tries := 0 8516 for { 8517 result, err := s.SystemStore.Get() 8518 if err == nil { 8519 return result, nil 8520 } 8521 if !isRepeatableError(err) { 8522 return result, err 8523 } 8524 tries++ 8525 if tries >= 3 { 8526 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8527 return result, err 8528 } 8529 } 8530 8531} 8532 8533func (s *RetryLayerSystemStore) GetByName(name string) (*model.System, error) { 8534 8535 tries := 0 8536 for { 8537 result, err := s.SystemStore.GetByName(name) 8538 if err == nil { 8539 return result, nil 8540 } 8541 if !isRepeatableError(err) { 8542 return result, err 8543 } 8544 tries++ 8545 if tries >= 3 { 8546 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8547 return result, err 8548 } 8549 } 8550 8551} 8552 8553func (s *RetryLayerSystemStore) InsertIfExists(system *model.System) (*model.System, error) { 8554 8555 tries := 0 8556 for { 8557 result, err := s.SystemStore.InsertIfExists(system) 8558 if err == nil { 8559 return result, nil 8560 } 8561 if !isRepeatableError(err) { 8562 return result, err 8563 } 8564 tries++ 8565 if tries >= 3 { 8566 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8567 return result, err 8568 } 8569 } 8570 8571} 8572 8573func (s *RetryLayerSystemStore) PermanentDeleteByName(name string) (*model.System, error) { 8574 8575 tries := 0 8576 for { 8577 result, err := s.SystemStore.PermanentDeleteByName(name) 8578 if err == nil { 8579 return result, nil 8580 } 8581 if !isRepeatableError(err) { 8582 return result, err 8583 } 8584 tries++ 8585 if tries >= 3 { 8586 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8587 return result, err 8588 } 8589 } 8590 8591} 8592 8593func (s *RetryLayerSystemStore) Save(system *model.System) error { 8594 8595 tries := 0 8596 for { 8597 err := s.SystemStore.Save(system) 8598 if err == nil { 8599 return nil 8600 } 8601 if !isRepeatableError(err) { 8602 return err 8603 } 8604 tries++ 8605 if tries >= 3 { 8606 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8607 return err 8608 } 8609 } 8610 8611} 8612 8613func (s *RetryLayerSystemStore) SaveOrUpdate(system *model.System) error { 8614 8615 tries := 0 8616 for { 8617 err := s.SystemStore.SaveOrUpdate(system) 8618 if err == nil { 8619 return nil 8620 } 8621 if !isRepeatableError(err) { 8622 return err 8623 } 8624 tries++ 8625 if tries >= 3 { 8626 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8627 return err 8628 } 8629 } 8630 8631} 8632 8633func (s *RetryLayerSystemStore) SaveOrUpdateWithWarnMetricHandling(system *model.System) error { 8634 8635 tries := 0 8636 for { 8637 err := s.SystemStore.SaveOrUpdateWithWarnMetricHandling(system) 8638 if err == nil { 8639 return nil 8640 } 8641 if !isRepeatableError(err) { 8642 return err 8643 } 8644 tries++ 8645 if tries >= 3 { 8646 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8647 return err 8648 } 8649 } 8650 8651} 8652 8653func (s *RetryLayerSystemStore) Update(system *model.System) error { 8654 8655 tries := 0 8656 for { 8657 err := s.SystemStore.Update(system) 8658 if err == nil { 8659 return nil 8660 } 8661 if !isRepeatableError(err) { 8662 return err 8663 } 8664 tries++ 8665 if tries >= 3 { 8666 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8667 return err 8668 } 8669 } 8670 8671} 8672 8673func (s *RetryLayerTeamStore) AnalyticsGetTeamCountForScheme(schemeID string) (int64, error) { 8674 8675 tries := 0 8676 for { 8677 result, err := s.TeamStore.AnalyticsGetTeamCountForScheme(schemeID) 8678 if err == nil { 8679 return result, nil 8680 } 8681 if !isRepeatableError(err) { 8682 return result, err 8683 } 8684 tries++ 8685 if tries >= 3 { 8686 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8687 return result, err 8688 } 8689 } 8690 8691} 8692 8693func (s *RetryLayerTeamStore) AnalyticsTeamCount(opts *model.TeamSearch) (int64, error) { 8694 8695 tries := 0 8696 for { 8697 result, err := s.TeamStore.AnalyticsTeamCount(opts) 8698 if err == nil { 8699 return result, nil 8700 } 8701 if !isRepeatableError(err) { 8702 return result, err 8703 } 8704 tries++ 8705 if tries >= 3 { 8706 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8707 return result, err 8708 } 8709 } 8710 8711} 8712 8713func (s *RetryLayerTeamStore) ClearAllCustomRoleAssignments() error { 8714 8715 tries := 0 8716 for { 8717 err := s.TeamStore.ClearAllCustomRoleAssignments() 8718 if err == nil { 8719 return nil 8720 } 8721 if !isRepeatableError(err) { 8722 return err 8723 } 8724 tries++ 8725 if tries >= 3 { 8726 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8727 return err 8728 } 8729 } 8730 8731} 8732 8733func (s *RetryLayerTeamStore) ClearCaches() { 8734 8735 s.TeamStore.ClearCaches() 8736 8737} 8738 8739func (s *RetryLayerTeamStore) Get(id string) (*model.Team, error) { 8740 8741 tries := 0 8742 for { 8743 result, err := s.TeamStore.Get(id) 8744 if err == nil { 8745 return result, nil 8746 } 8747 if !isRepeatableError(err) { 8748 return result, err 8749 } 8750 tries++ 8751 if tries >= 3 { 8752 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8753 return result, err 8754 } 8755 } 8756 8757} 8758 8759func (s *RetryLayerTeamStore) GetActiveMemberCount(teamID string, restrictions *model.ViewUsersRestrictions) (int64, error) { 8760 8761 tries := 0 8762 for { 8763 result, err := s.TeamStore.GetActiveMemberCount(teamID, restrictions) 8764 if err == nil { 8765 return result, nil 8766 } 8767 if !isRepeatableError(err) { 8768 return result, err 8769 } 8770 tries++ 8771 if tries >= 3 { 8772 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8773 return result, err 8774 } 8775 } 8776 8777} 8778 8779func (s *RetryLayerTeamStore) GetAll() ([]*model.Team, error) { 8780 8781 tries := 0 8782 for { 8783 result, err := s.TeamStore.GetAll() 8784 if err == nil { 8785 return result, nil 8786 } 8787 if !isRepeatableError(err) { 8788 return result, err 8789 } 8790 tries++ 8791 if tries >= 3 { 8792 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8793 return result, err 8794 } 8795 } 8796 8797} 8798 8799func (s *RetryLayerTeamStore) GetAllForExportAfter(limit int, afterID string) ([]*model.TeamForExport, error) { 8800 8801 tries := 0 8802 for { 8803 result, err := s.TeamStore.GetAllForExportAfter(limit, afterID) 8804 if err == nil { 8805 return result, nil 8806 } 8807 if !isRepeatableError(err) { 8808 return result, err 8809 } 8810 tries++ 8811 if tries >= 3 { 8812 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8813 return result, err 8814 } 8815 } 8816 8817} 8818 8819func (s *RetryLayerTeamStore) GetAllPage(offset int, limit int, opts *model.TeamSearch) ([]*model.Team, error) { 8820 8821 tries := 0 8822 for { 8823 result, err := s.TeamStore.GetAllPage(offset, limit, opts) 8824 if err == nil { 8825 return result, nil 8826 } 8827 if !isRepeatableError(err) { 8828 return result, err 8829 } 8830 tries++ 8831 if tries >= 3 { 8832 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8833 return result, err 8834 } 8835 } 8836 8837} 8838 8839func (s *RetryLayerTeamStore) GetAllPrivateTeamListing() ([]*model.Team, error) { 8840 8841 tries := 0 8842 for { 8843 result, err := s.TeamStore.GetAllPrivateTeamListing() 8844 if err == nil { 8845 return result, nil 8846 } 8847 if !isRepeatableError(err) { 8848 return result, err 8849 } 8850 tries++ 8851 if tries >= 3 { 8852 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8853 return result, err 8854 } 8855 } 8856 8857} 8858 8859func (s *RetryLayerTeamStore) GetAllTeamListing() ([]*model.Team, error) { 8860 8861 tries := 0 8862 for { 8863 result, err := s.TeamStore.GetAllTeamListing() 8864 if err == nil { 8865 return result, nil 8866 } 8867 if !isRepeatableError(err) { 8868 return result, err 8869 } 8870 tries++ 8871 if tries >= 3 { 8872 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8873 return result, err 8874 } 8875 } 8876 8877} 8878 8879func (s *RetryLayerTeamStore) GetByInviteId(inviteID string) (*model.Team, error) { 8880 8881 tries := 0 8882 for { 8883 result, err := s.TeamStore.GetByInviteId(inviteID) 8884 if err == nil { 8885 return result, nil 8886 } 8887 if !isRepeatableError(err) { 8888 return result, err 8889 } 8890 tries++ 8891 if tries >= 3 { 8892 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8893 return result, err 8894 } 8895 } 8896 8897} 8898 8899func (s *RetryLayerTeamStore) GetByName(name string) (*model.Team, error) { 8900 8901 tries := 0 8902 for { 8903 result, err := s.TeamStore.GetByName(name) 8904 if err == nil { 8905 return result, nil 8906 } 8907 if !isRepeatableError(err) { 8908 return result, err 8909 } 8910 tries++ 8911 if tries >= 3 { 8912 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8913 return result, err 8914 } 8915 } 8916 8917} 8918 8919func (s *RetryLayerTeamStore) GetByNames(name []string) ([]*model.Team, error) { 8920 8921 tries := 0 8922 for { 8923 result, err := s.TeamStore.GetByNames(name) 8924 if err == nil { 8925 return result, nil 8926 } 8927 if !isRepeatableError(err) { 8928 return result, err 8929 } 8930 tries++ 8931 if tries >= 3 { 8932 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8933 return result, err 8934 } 8935 } 8936 8937} 8938 8939func (s *RetryLayerTeamStore) GetChannelUnreadsForAllTeams(excludeTeamID string, userID string) ([]*model.ChannelUnread, error) { 8940 8941 tries := 0 8942 for { 8943 result, err := s.TeamStore.GetChannelUnreadsForAllTeams(excludeTeamID, userID) 8944 if err == nil { 8945 return result, nil 8946 } 8947 if !isRepeatableError(err) { 8948 return result, err 8949 } 8950 tries++ 8951 if tries >= 3 { 8952 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8953 return result, err 8954 } 8955 } 8956 8957} 8958 8959func (s *RetryLayerTeamStore) GetChannelUnreadsForTeam(teamID string, userID string) ([]*model.ChannelUnread, error) { 8960 8961 tries := 0 8962 for { 8963 result, err := s.TeamStore.GetChannelUnreadsForTeam(teamID, userID) 8964 if err == nil { 8965 return result, nil 8966 } 8967 if !isRepeatableError(err) { 8968 return result, err 8969 } 8970 tries++ 8971 if tries >= 3 { 8972 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8973 return result, err 8974 } 8975 } 8976 8977} 8978 8979func (s *RetryLayerTeamStore) GetCommonTeamIDsForTwoUsers(userID string, otherUserID string) ([]string, error) { 8980 8981 tries := 0 8982 for { 8983 result, err := s.TeamStore.GetCommonTeamIDsForTwoUsers(userID, otherUserID) 8984 if err == nil { 8985 return result, nil 8986 } 8987 if !isRepeatableError(err) { 8988 return result, err 8989 } 8990 tries++ 8991 if tries >= 3 { 8992 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 8993 return result, err 8994 } 8995 } 8996 8997} 8998 8999func (s *RetryLayerTeamStore) GetMember(ctx context.Context, teamID string, userID string) (*model.TeamMember, error) { 9000 9001 tries := 0 9002 for { 9003 result, err := s.TeamStore.GetMember(ctx, teamID, userID) 9004 if err == nil { 9005 return result, nil 9006 } 9007 if !isRepeatableError(err) { 9008 return result, err 9009 } 9010 tries++ 9011 if tries >= 3 { 9012 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9013 return result, err 9014 } 9015 } 9016 9017} 9018 9019func (s *RetryLayerTeamStore) GetMembers(teamID string, offset int, limit int, teamMembersGetOptions *model.TeamMembersGetOptions) ([]*model.TeamMember, error) { 9020 9021 tries := 0 9022 for { 9023 result, err := s.TeamStore.GetMembers(teamID, offset, limit, teamMembersGetOptions) 9024 if err == nil { 9025 return result, nil 9026 } 9027 if !isRepeatableError(err) { 9028 return result, err 9029 } 9030 tries++ 9031 if tries >= 3 { 9032 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9033 return result, err 9034 } 9035 } 9036 9037} 9038 9039func (s *RetryLayerTeamStore) GetMembersByIds(teamID string, userIds []string, restrictions *model.ViewUsersRestrictions) ([]*model.TeamMember, error) { 9040 9041 tries := 0 9042 for { 9043 result, err := s.TeamStore.GetMembersByIds(teamID, userIds, restrictions) 9044 if err == nil { 9045 return result, nil 9046 } 9047 if !isRepeatableError(err) { 9048 return result, err 9049 } 9050 tries++ 9051 if tries >= 3 { 9052 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9053 return result, err 9054 } 9055 } 9056 9057} 9058 9059func (s *RetryLayerTeamStore) GetTeamMembersForExport(userID string) ([]*model.TeamMemberForExport, error) { 9060 9061 tries := 0 9062 for { 9063 result, err := s.TeamStore.GetTeamMembersForExport(userID) 9064 if err == nil { 9065 return result, nil 9066 } 9067 if !isRepeatableError(err) { 9068 return result, err 9069 } 9070 tries++ 9071 if tries >= 3 { 9072 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9073 return result, err 9074 } 9075 } 9076 9077} 9078 9079func (s *RetryLayerTeamStore) GetTeamsByScheme(schemeID string, offset int, limit int) ([]*model.Team, error) { 9080 9081 tries := 0 9082 for { 9083 result, err := s.TeamStore.GetTeamsByScheme(schemeID, offset, limit) 9084 if err == nil { 9085 return result, nil 9086 } 9087 if !isRepeatableError(err) { 9088 return result, err 9089 } 9090 tries++ 9091 if tries >= 3 { 9092 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9093 return result, err 9094 } 9095 } 9096 9097} 9098 9099func (s *RetryLayerTeamStore) GetTeamsByUserId(userID string) ([]*model.Team, error) { 9100 9101 tries := 0 9102 for { 9103 result, err := s.TeamStore.GetTeamsByUserId(userID) 9104 if err == nil { 9105 return result, nil 9106 } 9107 if !isRepeatableError(err) { 9108 return result, err 9109 } 9110 tries++ 9111 if tries >= 3 { 9112 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9113 return result, err 9114 } 9115 } 9116 9117} 9118 9119func (s *RetryLayerTeamStore) GetTeamsForUser(ctx context.Context, userID string) ([]*model.TeamMember, error) { 9120 9121 tries := 0 9122 for { 9123 result, err := s.TeamStore.GetTeamsForUser(ctx, userID) 9124 if err == nil { 9125 return result, nil 9126 } 9127 if !isRepeatableError(err) { 9128 return result, err 9129 } 9130 tries++ 9131 if tries >= 3 { 9132 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9133 return result, err 9134 } 9135 } 9136 9137} 9138 9139func (s *RetryLayerTeamStore) GetTeamsForUserWithPagination(userID string, page int, perPage int) ([]*model.TeamMember, error) { 9140 9141 tries := 0 9142 for { 9143 result, err := s.TeamStore.GetTeamsForUserWithPagination(userID, page, perPage) 9144 if err == nil { 9145 return result, nil 9146 } 9147 if !isRepeatableError(err) { 9148 return result, err 9149 } 9150 tries++ 9151 if tries >= 3 { 9152 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9153 return result, err 9154 } 9155 } 9156 9157} 9158 9159func (s *RetryLayerTeamStore) GetTotalMemberCount(teamID string, restrictions *model.ViewUsersRestrictions) (int64, error) { 9160 9161 tries := 0 9162 for { 9163 result, err := s.TeamStore.GetTotalMemberCount(teamID, restrictions) 9164 if err == nil { 9165 return result, nil 9166 } 9167 if !isRepeatableError(err) { 9168 return result, err 9169 } 9170 tries++ 9171 if tries >= 3 { 9172 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9173 return result, err 9174 } 9175 } 9176 9177} 9178 9179func (s *RetryLayerTeamStore) GetUserTeamIds(userID string, allowFromCache bool) ([]string, error) { 9180 9181 tries := 0 9182 for { 9183 result, err := s.TeamStore.GetUserTeamIds(userID, allowFromCache) 9184 if err == nil { 9185 return result, nil 9186 } 9187 if !isRepeatableError(err) { 9188 return result, err 9189 } 9190 tries++ 9191 if tries >= 3 { 9192 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9193 return result, err 9194 } 9195 } 9196 9197} 9198 9199func (s *RetryLayerTeamStore) GroupSyncedTeamCount() (int64, error) { 9200 9201 tries := 0 9202 for { 9203 result, err := s.TeamStore.GroupSyncedTeamCount() 9204 if err == nil { 9205 return result, nil 9206 } 9207 if !isRepeatableError(err) { 9208 return result, err 9209 } 9210 tries++ 9211 if tries >= 3 { 9212 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9213 return result, err 9214 } 9215 } 9216 9217} 9218 9219func (s *RetryLayerTeamStore) InvalidateAllTeamIdsForUser(userID string) { 9220 9221 s.TeamStore.InvalidateAllTeamIdsForUser(userID) 9222 9223} 9224 9225func (s *RetryLayerTeamStore) MigrateTeamMembers(fromTeamID string, fromUserID string) (map[string]string, error) { 9226 9227 tries := 0 9228 for { 9229 result, err := s.TeamStore.MigrateTeamMembers(fromTeamID, fromUserID) 9230 if err == nil { 9231 return result, nil 9232 } 9233 if !isRepeatableError(err) { 9234 return result, err 9235 } 9236 tries++ 9237 if tries >= 3 { 9238 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9239 return result, err 9240 } 9241 } 9242 9243} 9244 9245func (s *RetryLayerTeamStore) PermanentDelete(teamID string) error { 9246 9247 tries := 0 9248 for { 9249 err := s.TeamStore.PermanentDelete(teamID) 9250 if err == nil { 9251 return nil 9252 } 9253 if !isRepeatableError(err) { 9254 return err 9255 } 9256 tries++ 9257 if tries >= 3 { 9258 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9259 return err 9260 } 9261 } 9262 9263} 9264 9265func (s *RetryLayerTeamStore) RemoveAllMembersByTeam(teamID string) error { 9266 9267 tries := 0 9268 for { 9269 err := s.TeamStore.RemoveAllMembersByTeam(teamID) 9270 if err == nil { 9271 return nil 9272 } 9273 if !isRepeatableError(err) { 9274 return err 9275 } 9276 tries++ 9277 if tries >= 3 { 9278 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9279 return err 9280 } 9281 } 9282 9283} 9284 9285func (s *RetryLayerTeamStore) RemoveAllMembersByUser(userID string) error { 9286 9287 tries := 0 9288 for { 9289 err := s.TeamStore.RemoveAllMembersByUser(userID) 9290 if err == nil { 9291 return nil 9292 } 9293 if !isRepeatableError(err) { 9294 return err 9295 } 9296 tries++ 9297 if tries >= 3 { 9298 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9299 return err 9300 } 9301 } 9302 9303} 9304 9305func (s *RetryLayerTeamStore) RemoveMember(teamID string, userID string) error { 9306 9307 tries := 0 9308 for { 9309 err := s.TeamStore.RemoveMember(teamID, userID) 9310 if err == nil { 9311 return nil 9312 } 9313 if !isRepeatableError(err) { 9314 return err 9315 } 9316 tries++ 9317 if tries >= 3 { 9318 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9319 return err 9320 } 9321 } 9322 9323} 9324 9325func (s *RetryLayerTeamStore) RemoveMembers(teamID string, userIds []string) error { 9326 9327 tries := 0 9328 for { 9329 err := s.TeamStore.RemoveMembers(teamID, userIds) 9330 if err == nil { 9331 return nil 9332 } 9333 if !isRepeatableError(err) { 9334 return err 9335 } 9336 tries++ 9337 if tries >= 3 { 9338 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9339 return err 9340 } 9341 } 9342 9343} 9344 9345func (s *RetryLayerTeamStore) ResetAllTeamSchemes() error { 9346 9347 tries := 0 9348 for { 9349 err := s.TeamStore.ResetAllTeamSchemes() 9350 if err == nil { 9351 return nil 9352 } 9353 if !isRepeatableError(err) { 9354 return err 9355 } 9356 tries++ 9357 if tries >= 3 { 9358 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9359 return err 9360 } 9361 } 9362 9363} 9364 9365func (s *RetryLayerTeamStore) Save(team *model.Team) (*model.Team, error) { 9366 9367 tries := 0 9368 for { 9369 result, err := s.TeamStore.Save(team) 9370 if err == nil { 9371 return result, nil 9372 } 9373 if !isRepeatableError(err) { 9374 return result, err 9375 } 9376 tries++ 9377 if tries >= 3 { 9378 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9379 return result, err 9380 } 9381 } 9382 9383} 9384 9385func (s *RetryLayerTeamStore) SaveMember(member *model.TeamMember, maxUsersPerTeam int) (*model.TeamMember, error) { 9386 9387 tries := 0 9388 for { 9389 result, err := s.TeamStore.SaveMember(member, maxUsersPerTeam) 9390 if err == nil { 9391 return result, nil 9392 } 9393 if !isRepeatableError(err) { 9394 return result, err 9395 } 9396 tries++ 9397 if tries >= 3 { 9398 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9399 return result, err 9400 } 9401 } 9402 9403} 9404 9405func (s *RetryLayerTeamStore) SaveMultipleMembers(members []*model.TeamMember, maxUsersPerTeam int) ([]*model.TeamMember, error) { 9406 9407 tries := 0 9408 for { 9409 result, err := s.TeamStore.SaveMultipleMembers(members, maxUsersPerTeam) 9410 if err == nil { 9411 return result, nil 9412 } 9413 if !isRepeatableError(err) { 9414 return result, err 9415 } 9416 tries++ 9417 if tries >= 3 { 9418 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9419 return result, err 9420 } 9421 } 9422 9423} 9424 9425func (s *RetryLayerTeamStore) SearchAll(opts *model.TeamSearch) ([]*model.Team, error) { 9426 9427 tries := 0 9428 for { 9429 result, err := s.TeamStore.SearchAll(opts) 9430 if err == nil { 9431 return result, nil 9432 } 9433 if !isRepeatableError(err) { 9434 return result, err 9435 } 9436 tries++ 9437 if tries >= 3 { 9438 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9439 return result, err 9440 } 9441 } 9442 9443} 9444 9445func (s *RetryLayerTeamStore) SearchAllPaged(opts *model.TeamSearch) ([]*model.Team, int64, error) { 9446 9447 tries := 0 9448 for { 9449 result, resultVar1, err := s.TeamStore.SearchAllPaged(opts) 9450 if err == nil { 9451 return result, resultVar1, nil 9452 } 9453 if !isRepeatableError(err) { 9454 return result, resultVar1, err 9455 } 9456 tries++ 9457 if tries >= 3 { 9458 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9459 return result, resultVar1, err 9460 } 9461 } 9462 9463} 9464 9465func (s *RetryLayerTeamStore) SearchOpen(opts *model.TeamSearch) ([]*model.Team, error) { 9466 9467 tries := 0 9468 for { 9469 result, err := s.TeamStore.SearchOpen(opts) 9470 if err == nil { 9471 return result, nil 9472 } 9473 if !isRepeatableError(err) { 9474 return result, err 9475 } 9476 tries++ 9477 if tries >= 3 { 9478 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9479 return result, err 9480 } 9481 } 9482 9483} 9484 9485func (s *RetryLayerTeamStore) SearchPrivate(opts *model.TeamSearch) ([]*model.Team, error) { 9486 9487 tries := 0 9488 for { 9489 result, err := s.TeamStore.SearchPrivate(opts) 9490 if err == nil { 9491 return result, nil 9492 } 9493 if !isRepeatableError(err) { 9494 return result, err 9495 } 9496 tries++ 9497 if tries >= 3 { 9498 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9499 return result, err 9500 } 9501 } 9502 9503} 9504 9505func (s *RetryLayerTeamStore) Update(team *model.Team) (*model.Team, error) { 9506 9507 tries := 0 9508 for { 9509 result, err := s.TeamStore.Update(team) 9510 if err == nil { 9511 return result, nil 9512 } 9513 if !isRepeatableError(err) { 9514 return result, err 9515 } 9516 tries++ 9517 if tries >= 3 { 9518 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9519 return result, err 9520 } 9521 } 9522 9523} 9524 9525func (s *RetryLayerTeamStore) UpdateLastTeamIconUpdate(teamID string, curTime int64) error { 9526 9527 tries := 0 9528 for { 9529 err := s.TeamStore.UpdateLastTeamIconUpdate(teamID, curTime) 9530 if err == nil { 9531 return nil 9532 } 9533 if !isRepeatableError(err) { 9534 return err 9535 } 9536 tries++ 9537 if tries >= 3 { 9538 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9539 return err 9540 } 9541 } 9542 9543} 9544 9545func (s *RetryLayerTeamStore) UpdateMember(member *model.TeamMember) (*model.TeamMember, error) { 9546 9547 tries := 0 9548 for { 9549 result, err := s.TeamStore.UpdateMember(member) 9550 if err == nil { 9551 return result, nil 9552 } 9553 if !isRepeatableError(err) { 9554 return result, err 9555 } 9556 tries++ 9557 if tries >= 3 { 9558 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9559 return result, err 9560 } 9561 } 9562 9563} 9564 9565func (s *RetryLayerTeamStore) UpdateMembersRole(teamID string, userIDs []string) error { 9566 9567 tries := 0 9568 for { 9569 err := s.TeamStore.UpdateMembersRole(teamID, userIDs) 9570 if err == nil { 9571 return nil 9572 } 9573 if !isRepeatableError(err) { 9574 return err 9575 } 9576 tries++ 9577 if tries >= 3 { 9578 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9579 return err 9580 } 9581 } 9582 9583} 9584 9585func (s *RetryLayerTeamStore) UpdateMultipleMembers(members []*model.TeamMember) ([]*model.TeamMember, error) { 9586 9587 tries := 0 9588 for { 9589 result, err := s.TeamStore.UpdateMultipleMembers(members) 9590 if err == nil { 9591 return result, nil 9592 } 9593 if !isRepeatableError(err) { 9594 return result, err 9595 } 9596 tries++ 9597 if tries >= 3 { 9598 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9599 return result, err 9600 } 9601 } 9602 9603} 9604 9605func (s *RetryLayerTeamStore) UserBelongsToTeams(userID string, teamIds []string) (bool, error) { 9606 9607 tries := 0 9608 for { 9609 result, err := s.TeamStore.UserBelongsToTeams(userID, teamIds) 9610 if err == nil { 9611 return result, nil 9612 } 9613 if !isRepeatableError(err) { 9614 return result, err 9615 } 9616 tries++ 9617 if tries >= 3 { 9618 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9619 return result, err 9620 } 9621 } 9622 9623} 9624 9625func (s *RetryLayerTermsOfServiceStore) Get(id string, allowFromCache bool) (*model.TermsOfService, error) { 9626 9627 tries := 0 9628 for { 9629 result, err := s.TermsOfServiceStore.Get(id, allowFromCache) 9630 if err == nil { 9631 return result, nil 9632 } 9633 if !isRepeatableError(err) { 9634 return result, err 9635 } 9636 tries++ 9637 if tries >= 3 { 9638 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9639 return result, err 9640 } 9641 } 9642 9643} 9644 9645func (s *RetryLayerTermsOfServiceStore) GetLatest(allowFromCache bool) (*model.TermsOfService, error) { 9646 9647 tries := 0 9648 for { 9649 result, err := s.TermsOfServiceStore.GetLatest(allowFromCache) 9650 if err == nil { 9651 return result, nil 9652 } 9653 if !isRepeatableError(err) { 9654 return result, err 9655 } 9656 tries++ 9657 if tries >= 3 { 9658 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9659 return result, err 9660 } 9661 } 9662 9663} 9664 9665func (s *RetryLayerTermsOfServiceStore) Save(termsOfService *model.TermsOfService) (*model.TermsOfService, error) { 9666 9667 tries := 0 9668 for { 9669 result, err := s.TermsOfServiceStore.Save(termsOfService) 9670 if err == nil { 9671 return result, nil 9672 } 9673 if !isRepeatableError(err) { 9674 return result, err 9675 } 9676 tries++ 9677 if tries >= 3 { 9678 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9679 return result, err 9680 } 9681 } 9682 9683} 9684 9685func (s *RetryLayerThreadStore) CollectThreadsWithNewerReplies(userId string, channelIds []string, timestamp int64) ([]string, error) { 9686 9687 tries := 0 9688 for { 9689 result, err := s.ThreadStore.CollectThreadsWithNewerReplies(userId, channelIds, timestamp) 9690 if err == nil { 9691 return result, nil 9692 } 9693 if !isRepeatableError(err) { 9694 return result, err 9695 } 9696 tries++ 9697 if tries >= 3 { 9698 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9699 return result, err 9700 } 9701 } 9702 9703} 9704 9705func (s *RetryLayerThreadStore) Delete(postID string) error { 9706 9707 tries := 0 9708 for { 9709 err := s.ThreadStore.Delete(postID) 9710 if err == nil { 9711 return nil 9712 } 9713 if !isRepeatableError(err) { 9714 return err 9715 } 9716 tries++ 9717 if tries >= 3 { 9718 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9719 return err 9720 } 9721 } 9722 9723} 9724 9725func (s *RetryLayerThreadStore) DeleteMembershipForUser(userId string, postID string) error { 9726 9727 tries := 0 9728 for { 9729 err := s.ThreadStore.DeleteMembershipForUser(userId, postID) 9730 if err == nil { 9731 return nil 9732 } 9733 if !isRepeatableError(err) { 9734 return err 9735 } 9736 tries++ 9737 if tries >= 3 { 9738 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9739 return err 9740 } 9741 } 9742 9743} 9744 9745func (s *RetryLayerThreadStore) DeleteOrphanedRows(limit int) (int64, error) { 9746 9747 tries := 0 9748 for { 9749 result, err := s.ThreadStore.DeleteOrphanedRows(limit) 9750 if err == nil { 9751 return result, nil 9752 } 9753 if !isRepeatableError(err) { 9754 return result, err 9755 } 9756 tries++ 9757 if tries >= 3 { 9758 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9759 return result, err 9760 } 9761 } 9762 9763} 9764 9765func (s *RetryLayerThreadStore) Get(id string) (*model.Thread, error) { 9766 9767 tries := 0 9768 for { 9769 result, err := s.ThreadStore.Get(id) 9770 if err == nil { 9771 return result, nil 9772 } 9773 if !isRepeatableError(err) { 9774 return result, err 9775 } 9776 tries++ 9777 if tries >= 3 { 9778 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9779 return result, err 9780 } 9781 } 9782 9783} 9784 9785func (s *RetryLayerThreadStore) GetMembershipForUser(userId string, postID string) (*model.ThreadMembership, error) { 9786 9787 tries := 0 9788 for { 9789 result, err := s.ThreadStore.GetMembershipForUser(userId, postID) 9790 if err == nil { 9791 return result, nil 9792 } 9793 if !isRepeatableError(err) { 9794 return result, err 9795 } 9796 tries++ 9797 if tries >= 3 { 9798 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9799 return result, err 9800 } 9801 } 9802 9803} 9804 9805func (s *RetryLayerThreadStore) GetMembershipsForUser(userId string, teamID string) ([]*model.ThreadMembership, error) { 9806 9807 tries := 0 9808 for { 9809 result, err := s.ThreadStore.GetMembershipsForUser(userId, teamID) 9810 if err == nil { 9811 return result, nil 9812 } 9813 if !isRepeatableError(err) { 9814 return result, err 9815 } 9816 tries++ 9817 if tries >= 3 { 9818 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9819 return result, err 9820 } 9821 } 9822 9823} 9824 9825func (s *RetryLayerThreadStore) GetPosts(threadID string, since int64) ([]*model.Post, error) { 9826 9827 tries := 0 9828 for { 9829 result, err := s.ThreadStore.GetPosts(threadID, since) 9830 if err == nil { 9831 return result, nil 9832 } 9833 if !isRepeatableError(err) { 9834 return result, err 9835 } 9836 tries++ 9837 if tries >= 3 { 9838 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9839 return result, err 9840 } 9841 } 9842 9843} 9844 9845func (s *RetryLayerThreadStore) GetThreadFollowers(threadID string, fetchOnlyActive bool) ([]string, error) { 9846 9847 tries := 0 9848 for { 9849 result, err := s.ThreadStore.GetThreadFollowers(threadID, fetchOnlyActive) 9850 if err == nil { 9851 return result, nil 9852 } 9853 if !isRepeatableError(err) { 9854 return result, err 9855 } 9856 tries++ 9857 if tries >= 3 { 9858 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9859 return result, err 9860 } 9861 } 9862 9863} 9864 9865func (s *RetryLayerThreadStore) GetThreadForUser(teamID string, threadMembership *model.ThreadMembership, extended bool) (*model.ThreadResponse, error) { 9866 9867 tries := 0 9868 for { 9869 result, err := s.ThreadStore.GetThreadForUser(teamID, threadMembership, extended) 9870 if err == nil { 9871 return result, nil 9872 } 9873 if !isRepeatableError(err) { 9874 return result, err 9875 } 9876 tries++ 9877 if tries >= 3 { 9878 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9879 return result, err 9880 } 9881 } 9882 9883} 9884 9885func (s *RetryLayerThreadStore) GetThreadsForUser(userId string, teamID string, opts model.GetUserThreadsOpts) (*model.Threads, error) { 9886 9887 tries := 0 9888 for { 9889 result, err := s.ThreadStore.GetThreadsForUser(userId, teamID, opts) 9890 if err == nil { 9891 return result, nil 9892 } 9893 if !isRepeatableError(err) { 9894 return result, err 9895 } 9896 tries++ 9897 if tries >= 3 { 9898 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9899 return result, err 9900 } 9901 } 9902 9903} 9904 9905func (s *RetryLayerThreadStore) MaintainMembership(userID string, postID string, opts store.ThreadMembershipOpts) (*model.ThreadMembership, error) { 9906 9907 tries := 0 9908 for { 9909 result, err := s.ThreadStore.MaintainMembership(userID, postID, opts) 9910 if err == nil { 9911 return result, nil 9912 } 9913 if !isRepeatableError(err) { 9914 return result, err 9915 } 9916 tries++ 9917 if tries >= 3 { 9918 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9919 return result, err 9920 } 9921 } 9922 9923} 9924 9925func (s *RetryLayerThreadStore) MarkAllAsRead(userID string, teamID string) error { 9926 9927 tries := 0 9928 for { 9929 err := s.ThreadStore.MarkAllAsRead(userID, teamID) 9930 if err == nil { 9931 return nil 9932 } 9933 if !isRepeatableError(err) { 9934 return err 9935 } 9936 tries++ 9937 if tries >= 3 { 9938 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9939 return err 9940 } 9941 } 9942 9943} 9944 9945func (s *RetryLayerThreadStore) MarkAllAsReadInChannels(userID string, channelIDs []string) error { 9946 9947 tries := 0 9948 for { 9949 err := s.ThreadStore.MarkAllAsReadInChannels(userID, channelIDs) 9950 if err == nil { 9951 return nil 9952 } 9953 if !isRepeatableError(err) { 9954 return err 9955 } 9956 tries++ 9957 if tries >= 3 { 9958 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9959 return err 9960 } 9961 } 9962 9963} 9964 9965func (s *RetryLayerThreadStore) MarkAsRead(userID string, threadID string, timestamp int64) error { 9966 9967 tries := 0 9968 for { 9969 err := s.ThreadStore.MarkAsRead(userID, threadID, timestamp) 9970 if err == nil { 9971 return nil 9972 } 9973 if !isRepeatableError(err) { 9974 return err 9975 } 9976 tries++ 9977 if tries >= 3 { 9978 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9979 return err 9980 } 9981 } 9982 9983} 9984 9985func (s *RetryLayerThreadStore) PermanentDeleteBatchForRetentionPolicies(now int64, globalPolicyEndTime int64, limit int64, cursor model.RetentionPolicyCursor) (int64, model.RetentionPolicyCursor, error) { 9986 9987 tries := 0 9988 for { 9989 result, resultVar1, err := s.ThreadStore.PermanentDeleteBatchForRetentionPolicies(now, globalPolicyEndTime, limit, cursor) 9990 if err == nil { 9991 return result, resultVar1, nil 9992 } 9993 if !isRepeatableError(err) { 9994 return result, resultVar1, err 9995 } 9996 tries++ 9997 if tries >= 3 { 9998 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 9999 return result, resultVar1, err 10000 } 10001 } 10002 10003} 10004 10005func (s *RetryLayerThreadStore) PermanentDeleteBatchThreadMembershipsForRetentionPolicies(now int64, globalPolicyEndTime int64, limit int64, cursor model.RetentionPolicyCursor) (int64, model.RetentionPolicyCursor, error) { 10006 10007 tries := 0 10008 for { 10009 result, resultVar1, err := s.ThreadStore.PermanentDeleteBatchThreadMembershipsForRetentionPolicies(now, globalPolicyEndTime, limit, cursor) 10010 if err == nil { 10011 return result, resultVar1, nil 10012 } 10013 if !isRepeatableError(err) { 10014 return result, resultVar1, err 10015 } 10016 tries++ 10017 if tries >= 3 { 10018 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10019 return result, resultVar1, err 10020 } 10021 } 10022 10023} 10024 10025func (s *RetryLayerThreadStore) Save(thread *model.Thread) (*model.Thread, error) { 10026 10027 tries := 0 10028 for { 10029 result, err := s.ThreadStore.Save(thread) 10030 if err == nil { 10031 return result, nil 10032 } 10033 if !isRepeatableError(err) { 10034 return result, err 10035 } 10036 tries++ 10037 if tries >= 3 { 10038 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10039 return result, err 10040 } 10041 } 10042 10043} 10044 10045func (s *RetryLayerThreadStore) SaveMembership(membership *model.ThreadMembership) (*model.ThreadMembership, error) { 10046 10047 tries := 0 10048 for { 10049 result, err := s.ThreadStore.SaveMembership(membership) 10050 if err == nil { 10051 return result, nil 10052 } 10053 if !isRepeatableError(err) { 10054 return result, err 10055 } 10056 tries++ 10057 if tries >= 3 { 10058 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10059 return result, err 10060 } 10061 } 10062 10063} 10064 10065func (s *RetryLayerThreadStore) SaveMultiple(thread []*model.Thread) ([]*model.Thread, int, error) { 10066 10067 tries := 0 10068 for { 10069 result, resultVar1, err := s.ThreadStore.SaveMultiple(thread) 10070 if err == nil { 10071 return result, resultVar1, nil 10072 } 10073 if !isRepeatableError(err) { 10074 return result, resultVar1, err 10075 } 10076 tries++ 10077 if tries >= 3 { 10078 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10079 return result, resultVar1, err 10080 } 10081 } 10082 10083} 10084 10085func (s *RetryLayerThreadStore) Update(thread *model.Thread) (*model.Thread, error) { 10086 10087 tries := 0 10088 for { 10089 result, err := s.ThreadStore.Update(thread) 10090 if err == nil { 10091 return result, nil 10092 } 10093 if !isRepeatableError(err) { 10094 return result, err 10095 } 10096 tries++ 10097 if tries >= 3 { 10098 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10099 return result, err 10100 } 10101 } 10102 10103} 10104 10105func (s *RetryLayerThreadStore) UpdateMembership(membership *model.ThreadMembership) (*model.ThreadMembership, error) { 10106 10107 tries := 0 10108 for { 10109 result, err := s.ThreadStore.UpdateMembership(membership) 10110 if err == nil { 10111 return result, nil 10112 } 10113 if !isRepeatableError(err) { 10114 return result, err 10115 } 10116 tries++ 10117 if tries >= 3 { 10118 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10119 return result, err 10120 } 10121 } 10122 10123} 10124 10125func (s *RetryLayerThreadStore) UpdateUnreadsByChannel(userId string, changedThreads []string, timestamp int64, updateViewedTimestamp bool) error { 10126 10127 tries := 0 10128 for { 10129 err := s.ThreadStore.UpdateUnreadsByChannel(userId, changedThreads, timestamp, updateViewedTimestamp) 10130 if err == nil { 10131 return nil 10132 } 10133 if !isRepeatableError(err) { 10134 return err 10135 } 10136 tries++ 10137 if tries >= 3 { 10138 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10139 return err 10140 } 10141 } 10142 10143} 10144 10145func (s *RetryLayerTokenStore) Cleanup() { 10146 10147 s.TokenStore.Cleanup() 10148 10149} 10150 10151func (s *RetryLayerTokenStore) Delete(token string) error { 10152 10153 tries := 0 10154 for { 10155 err := s.TokenStore.Delete(token) 10156 if err == nil { 10157 return nil 10158 } 10159 if !isRepeatableError(err) { 10160 return err 10161 } 10162 tries++ 10163 if tries >= 3 { 10164 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10165 return err 10166 } 10167 } 10168 10169} 10170 10171func (s *RetryLayerTokenStore) GetAllTokensByType(tokenType string) ([]*model.Token, error) { 10172 10173 tries := 0 10174 for { 10175 result, err := s.TokenStore.GetAllTokensByType(tokenType) 10176 if err == nil { 10177 return result, nil 10178 } 10179 if !isRepeatableError(err) { 10180 return result, err 10181 } 10182 tries++ 10183 if tries >= 3 { 10184 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10185 return result, err 10186 } 10187 } 10188 10189} 10190 10191func (s *RetryLayerTokenStore) GetByToken(token string) (*model.Token, error) { 10192 10193 tries := 0 10194 for { 10195 result, err := s.TokenStore.GetByToken(token) 10196 if err == nil { 10197 return result, nil 10198 } 10199 if !isRepeatableError(err) { 10200 return result, err 10201 } 10202 tries++ 10203 if tries >= 3 { 10204 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10205 return result, err 10206 } 10207 } 10208 10209} 10210 10211func (s *RetryLayerTokenStore) RemoveAllTokensByType(tokenType string) error { 10212 10213 tries := 0 10214 for { 10215 err := s.TokenStore.RemoveAllTokensByType(tokenType) 10216 if err == nil { 10217 return nil 10218 } 10219 if !isRepeatableError(err) { 10220 return err 10221 } 10222 tries++ 10223 if tries >= 3 { 10224 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10225 return err 10226 } 10227 } 10228 10229} 10230 10231func (s *RetryLayerTokenStore) Save(recovery *model.Token) error { 10232 10233 tries := 0 10234 for { 10235 err := s.TokenStore.Save(recovery) 10236 if err == nil { 10237 return nil 10238 } 10239 if !isRepeatableError(err) { 10240 return err 10241 } 10242 tries++ 10243 if tries >= 3 { 10244 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10245 return err 10246 } 10247 } 10248 10249} 10250 10251func (s *RetryLayerUploadSessionStore) Delete(id string) error { 10252 10253 tries := 0 10254 for { 10255 err := s.UploadSessionStore.Delete(id) 10256 if err == nil { 10257 return nil 10258 } 10259 if !isRepeatableError(err) { 10260 return err 10261 } 10262 tries++ 10263 if tries >= 3 { 10264 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10265 return err 10266 } 10267 } 10268 10269} 10270 10271func (s *RetryLayerUploadSessionStore) Get(id string) (*model.UploadSession, error) { 10272 10273 tries := 0 10274 for { 10275 result, err := s.UploadSessionStore.Get(id) 10276 if err == nil { 10277 return result, nil 10278 } 10279 if !isRepeatableError(err) { 10280 return result, err 10281 } 10282 tries++ 10283 if tries >= 3 { 10284 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10285 return result, err 10286 } 10287 } 10288 10289} 10290 10291func (s *RetryLayerUploadSessionStore) GetForUser(userID string) ([]*model.UploadSession, error) { 10292 10293 tries := 0 10294 for { 10295 result, err := s.UploadSessionStore.GetForUser(userID) 10296 if err == nil { 10297 return result, nil 10298 } 10299 if !isRepeatableError(err) { 10300 return result, err 10301 } 10302 tries++ 10303 if tries >= 3 { 10304 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10305 return result, err 10306 } 10307 } 10308 10309} 10310 10311func (s *RetryLayerUploadSessionStore) Save(session *model.UploadSession) (*model.UploadSession, error) { 10312 10313 tries := 0 10314 for { 10315 result, err := s.UploadSessionStore.Save(session) 10316 if err == nil { 10317 return result, nil 10318 } 10319 if !isRepeatableError(err) { 10320 return result, err 10321 } 10322 tries++ 10323 if tries >= 3 { 10324 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10325 return result, err 10326 } 10327 } 10328 10329} 10330 10331func (s *RetryLayerUploadSessionStore) Update(session *model.UploadSession) error { 10332 10333 tries := 0 10334 for { 10335 err := s.UploadSessionStore.Update(session) 10336 if err == nil { 10337 return nil 10338 } 10339 if !isRepeatableError(err) { 10340 return err 10341 } 10342 tries++ 10343 if tries >= 3 { 10344 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10345 return err 10346 } 10347 } 10348 10349} 10350 10351func (s *RetryLayerUserStore) AnalyticsActiveCount(time int64, options model.UserCountOptions) (int64, error) { 10352 10353 tries := 0 10354 for { 10355 result, err := s.UserStore.AnalyticsActiveCount(time, options) 10356 if err == nil { 10357 return result, nil 10358 } 10359 if !isRepeatableError(err) { 10360 return result, err 10361 } 10362 tries++ 10363 if tries >= 3 { 10364 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10365 return result, err 10366 } 10367 } 10368 10369} 10370 10371func (s *RetryLayerUserStore) AnalyticsActiveCountForPeriod(startTime int64, endTime int64, options model.UserCountOptions) (int64, error) { 10372 10373 tries := 0 10374 for { 10375 result, err := s.UserStore.AnalyticsActiveCountForPeriod(startTime, endTime, options) 10376 if err == nil { 10377 return result, nil 10378 } 10379 if !isRepeatableError(err) { 10380 return result, err 10381 } 10382 tries++ 10383 if tries >= 3 { 10384 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10385 return result, err 10386 } 10387 } 10388 10389} 10390 10391func (s *RetryLayerUserStore) AnalyticsGetExternalUsers(hostDomain string) (bool, error) { 10392 10393 tries := 0 10394 for { 10395 result, err := s.UserStore.AnalyticsGetExternalUsers(hostDomain) 10396 if err == nil { 10397 return result, nil 10398 } 10399 if !isRepeatableError(err) { 10400 return result, err 10401 } 10402 tries++ 10403 if tries >= 3 { 10404 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10405 return result, err 10406 } 10407 } 10408 10409} 10410 10411func (s *RetryLayerUserStore) AnalyticsGetGuestCount() (int64, error) { 10412 10413 tries := 0 10414 for { 10415 result, err := s.UserStore.AnalyticsGetGuestCount() 10416 if err == nil { 10417 return result, nil 10418 } 10419 if !isRepeatableError(err) { 10420 return result, err 10421 } 10422 tries++ 10423 if tries >= 3 { 10424 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10425 return result, err 10426 } 10427 } 10428 10429} 10430 10431func (s *RetryLayerUserStore) AnalyticsGetInactiveUsersCount() (int64, error) { 10432 10433 tries := 0 10434 for { 10435 result, err := s.UserStore.AnalyticsGetInactiveUsersCount() 10436 if err == nil { 10437 return result, nil 10438 } 10439 if !isRepeatableError(err) { 10440 return result, err 10441 } 10442 tries++ 10443 if tries >= 3 { 10444 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10445 return result, err 10446 } 10447 } 10448 10449} 10450 10451func (s *RetryLayerUserStore) AnalyticsGetSystemAdminCount() (int64, error) { 10452 10453 tries := 0 10454 for { 10455 result, err := s.UserStore.AnalyticsGetSystemAdminCount() 10456 if err == nil { 10457 return result, nil 10458 } 10459 if !isRepeatableError(err) { 10460 return result, err 10461 } 10462 tries++ 10463 if tries >= 3 { 10464 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10465 return result, err 10466 } 10467 } 10468 10469} 10470 10471func (s *RetryLayerUserStore) AutocompleteUsersInChannel(teamID string, channelID string, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInChannel, error) { 10472 10473 tries := 0 10474 for { 10475 result, err := s.UserStore.AutocompleteUsersInChannel(teamID, channelID, term, options) 10476 if err == nil { 10477 return result, nil 10478 } 10479 if !isRepeatableError(err) { 10480 return result, err 10481 } 10482 tries++ 10483 if tries >= 3 { 10484 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10485 return result, err 10486 } 10487 } 10488 10489} 10490 10491func (s *RetryLayerUserStore) ClearAllCustomRoleAssignments() error { 10492 10493 tries := 0 10494 for { 10495 err := s.UserStore.ClearAllCustomRoleAssignments() 10496 if err == nil { 10497 return nil 10498 } 10499 if !isRepeatableError(err) { 10500 return err 10501 } 10502 tries++ 10503 if tries >= 3 { 10504 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10505 return err 10506 } 10507 } 10508 10509} 10510 10511func (s *RetryLayerUserStore) ClearCaches() { 10512 10513 s.UserStore.ClearCaches() 10514 10515} 10516 10517func (s *RetryLayerUserStore) Count(options model.UserCountOptions) (int64, error) { 10518 10519 tries := 0 10520 for { 10521 result, err := s.UserStore.Count(options) 10522 if err == nil { 10523 return result, nil 10524 } 10525 if !isRepeatableError(err) { 10526 return result, err 10527 } 10528 tries++ 10529 if tries >= 3 { 10530 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10531 return result, err 10532 } 10533 } 10534 10535} 10536 10537func (s *RetryLayerUserStore) DeactivateGuests() ([]string, error) { 10538 10539 tries := 0 10540 for { 10541 result, err := s.UserStore.DeactivateGuests() 10542 if err == nil { 10543 return result, nil 10544 } 10545 if !isRepeatableError(err) { 10546 return result, err 10547 } 10548 tries++ 10549 if tries >= 3 { 10550 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10551 return result, err 10552 } 10553 } 10554 10555} 10556 10557func (s *RetryLayerUserStore) DemoteUserToGuest(userID string) (*model.User, error) { 10558 10559 tries := 0 10560 for { 10561 result, err := s.UserStore.DemoteUserToGuest(userID) 10562 if err == nil { 10563 return result, nil 10564 } 10565 if !isRepeatableError(err) { 10566 return result, err 10567 } 10568 tries++ 10569 if tries >= 3 { 10570 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10571 return result, err 10572 } 10573 } 10574 10575} 10576 10577func (s *RetryLayerUserStore) Get(ctx context.Context, id string) (*model.User, error) { 10578 10579 tries := 0 10580 for { 10581 result, err := s.UserStore.Get(ctx, id) 10582 if err == nil { 10583 return result, nil 10584 } 10585 if !isRepeatableError(err) { 10586 return result, err 10587 } 10588 tries++ 10589 if tries >= 3 { 10590 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10591 return result, err 10592 } 10593 } 10594 10595} 10596 10597func (s *RetryLayerUserStore) GetAll() ([]*model.User, error) { 10598 10599 tries := 0 10600 for { 10601 result, err := s.UserStore.GetAll() 10602 if err == nil { 10603 return result, nil 10604 } 10605 if !isRepeatableError(err) { 10606 return result, err 10607 } 10608 tries++ 10609 if tries >= 3 { 10610 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10611 return result, err 10612 } 10613 } 10614 10615} 10616 10617func (s *RetryLayerUserStore) GetAllAfter(limit int, afterID string) ([]*model.User, error) { 10618 10619 tries := 0 10620 for { 10621 result, err := s.UserStore.GetAllAfter(limit, afterID) 10622 if err == nil { 10623 return result, nil 10624 } 10625 if !isRepeatableError(err) { 10626 return result, err 10627 } 10628 tries++ 10629 if tries >= 3 { 10630 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10631 return result, err 10632 } 10633 } 10634 10635} 10636 10637func (s *RetryLayerUserStore) GetAllNotInAuthService(authServices []string) ([]*model.User, error) { 10638 10639 tries := 0 10640 for { 10641 result, err := s.UserStore.GetAllNotInAuthService(authServices) 10642 if err == nil { 10643 return result, nil 10644 } 10645 if !isRepeatableError(err) { 10646 return result, err 10647 } 10648 tries++ 10649 if tries >= 3 { 10650 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10651 return result, err 10652 } 10653 } 10654 10655} 10656 10657func (s *RetryLayerUserStore) GetAllProfiles(options *model.UserGetOptions) ([]*model.User, error) { 10658 10659 tries := 0 10660 for { 10661 result, err := s.UserStore.GetAllProfiles(options) 10662 if err == nil { 10663 return result, nil 10664 } 10665 if !isRepeatableError(err) { 10666 return result, err 10667 } 10668 tries++ 10669 if tries >= 3 { 10670 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10671 return result, err 10672 } 10673 } 10674 10675} 10676 10677func (s *RetryLayerUserStore) GetAllProfilesInChannel(ctx context.Context, channelID string, allowFromCache bool) (map[string]*model.User, error) { 10678 10679 tries := 0 10680 for { 10681 result, err := s.UserStore.GetAllProfilesInChannel(ctx, channelID, allowFromCache) 10682 if err == nil { 10683 return result, nil 10684 } 10685 if !isRepeatableError(err) { 10686 return result, err 10687 } 10688 tries++ 10689 if tries >= 3 { 10690 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10691 return result, err 10692 } 10693 } 10694 10695} 10696 10697func (s *RetryLayerUserStore) GetAllUsingAuthService(authService string) ([]*model.User, error) { 10698 10699 tries := 0 10700 for { 10701 result, err := s.UserStore.GetAllUsingAuthService(authService) 10702 if err == nil { 10703 return result, nil 10704 } 10705 if !isRepeatableError(err) { 10706 return result, err 10707 } 10708 tries++ 10709 if tries >= 3 { 10710 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10711 return result, err 10712 } 10713 } 10714 10715} 10716 10717func (s *RetryLayerUserStore) GetAnyUnreadPostCountForChannel(userID string, channelID string) (int64, error) { 10718 10719 tries := 0 10720 for { 10721 result, err := s.UserStore.GetAnyUnreadPostCountForChannel(userID, channelID) 10722 if err == nil { 10723 return result, nil 10724 } 10725 if !isRepeatableError(err) { 10726 return result, err 10727 } 10728 tries++ 10729 if tries >= 3 { 10730 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10731 return result, err 10732 } 10733 } 10734 10735} 10736 10737func (s *RetryLayerUserStore) GetByAuth(authData *string, authService string) (*model.User, error) { 10738 10739 tries := 0 10740 for { 10741 result, err := s.UserStore.GetByAuth(authData, authService) 10742 if err == nil { 10743 return result, nil 10744 } 10745 if !isRepeatableError(err) { 10746 return result, err 10747 } 10748 tries++ 10749 if tries >= 3 { 10750 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10751 return result, err 10752 } 10753 } 10754 10755} 10756 10757func (s *RetryLayerUserStore) GetByEmail(email string) (*model.User, error) { 10758 10759 tries := 0 10760 for { 10761 result, err := s.UserStore.GetByEmail(email) 10762 if err == nil { 10763 return result, nil 10764 } 10765 if !isRepeatableError(err) { 10766 return result, err 10767 } 10768 tries++ 10769 if tries >= 3 { 10770 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10771 return result, err 10772 } 10773 } 10774 10775} 10776 10777func (s *RetryLayerUserStore) GetByUsername(username string) (*model.User, error) { 10778 10779 tries := 0 10780 for { 10781 result, err := s.UserStore.GetByUsername(username) 10782 if err == nil { 10783 return result, nil 10784 } 10785 if !isRepeatableError(err) { 10786 return result, err 10787 } 10788 tries++ 10789 if tries >= 3 { 10790 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10791 return result, err 10792 } 10793 } 10794 10795} 10796 10797func (s *RetryLayerUserStore) GetChannelGroupUsers(channelID string) ([]*model.User, error) { 10798 10799 tries := 0 10800 for { 10801 result, err := s.UserStore.GetChannelGroupUsers(channelID) 10802 if err == nil { 10803 return result, nil 10804 } 10805 if !isRepeatableError(err) { 10806 return result, err 10807 } 10808 tries++ 10809 if tries >= 3 { 10810 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10811 return result, err 10812 } 10813 } 10814 10815} 10816 10817func (s *RetryLayerUserStore) GetEtagForAllProfiles() string { 10818 10819 return s.UserStore.GetEtagForAllProfiles() 10820 10821} 10822 10823func (s *RetryLayerUserStore) GetEtagForProfiles(teamID string) string { 10824 10825 return s.UserStore.GetEtagForProfiles(teamID) 10826 10827} 10828 10829func (s *RetryLayerUserStore) GetEtagForProfilesNotInTeam(teamID string) string { 10830 10831 return s.UserStore.GetEtagForProfilesNotInTeam(teamID) 10832 10833} 10834 10835func (s *RetryLayerUserStore) GetForLogin(loginID string, allowSignInWithUsername bool, allowSignInWithEmail bool) (*model.User, error) { 10836 10837 tries := 0 10838 for { 10839 result, err := s.UserStore.GetForLogin(loginID, allowSignInWithUsername, allowSignInWithEmail) 10840 if err == nil { 10841 return result, nil 10842 } 10843 if !isRepeatableError(err) { 10844 return result, err 10845 } 10846 tries++ 10847 if tries >= 3 { 10848 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10849 return result, err 10850 } 10851 } 10852 10853} 10854 10855func (s *RetryLayerUserStore) GetKnownUsers(userID string) ([]string, error) { 10856 10857 tries := 0 10858 for { 10859 result, err := s.UserStore.GetKnownUsers(userID) 10860 if err == nil { 10861 return result, nil 10862 } 10863 if !isRepeatableError(err) { 10864 return result, err 10865 } 10866 tries++ 10867 if tries >= 3 { 10868 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10869 return result, err 10870 } 10871 } 10872 10873} 10874 10875func (s *RetryLayerUserStore) GetMany(ctx context.Context, ids []string) ([]*model.User, error) { 10876 10877 tries := 0 10878 for { 10879 result, err := s.UserStore.GetMany(ctx, ids) 10880 if err == nil { 10881 return result, nil 10882 } 10883 if !isRepeatableError(err) { 10884 return result, err 10885 } 10886 tries++ 10887 if tries >= 3 { 10888 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10889 return result, err 10890 } 10891 } 10892 10893} 10894 10895func (s *RetryLayerUserStore) GetNewUsersForTeam(teamID string, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error) { 10896 10897 tries := 0 10898 for { 10899 result, err := s.UserStore.GetNewUsersForTeam(teamID, offset, limit, viewRestrictions) 10900 if err == nil { 10901 return result, nil 10902 } 10903 if !isRepeatableError(err) { 10904 return result, err 10905 } 10906 tries++ 10907 if tries >= 3 { 10908 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10909 return result, err 10910 } 10911 } 10912 10913} 10914 10915func (s *RetryLayerUserStore) GetProfileByGroupChannelIdsForUser(userID string, channelIds []string) (map[string][]*model.User, error) { 10916 10917 tries := 0 10918 for { 10919 result, err := s.UserStore.GetProfileByGroupChannelIdsForUser(userID, channelIds) 10920 if err == nil { 10921 return result, nil 10922 } 10923 if !isRepeatableError(err) { 10924 return result, err 10925 } 10926 tries++ 10927 if tries >= 3 { 10928 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10929 return result, err 10930 } 10931 } 10932 10933} 10934 10935func (s *RetryLayerUserStore) GetProfileByIds(ctx context.Context, userIds []string, options *store.UserGetByIdsOpts, allowFromCache bool) ([]*model.User, error) { 10936 10937 tries := 0 10938 for { 10939 result, err := s.UserStore.GetProfileByIds(ctx, userIds, options, allowFromCache) 10940 if err == nil { 10941 return result, nil 10942 } 10943 if !isRepeatableError(err) { 10944 return result, err 10945 } 10946 tries++ 10947 if tries >= 3 { 10948 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10949 return result, err 10950 } 10951 } 10952 10953} 10954 10955func (s *RetryLayerUserStore) GetProfiles(options *model.UserGetOptions) ([]*model.User, error) { 10956 10957 tries := 0 10958 for { 10959 result, err := s.UserStore.GetProfiles(options) 10960 if err == nil { 10961 return result, nil 10962 } 10963 if !isRepeatableError(err) { 10964 return result, err 10965 } 10966 tries++ 10967 if tries >= 3 { 10968 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10969 return result, err 10970 } 10971 } 10972 10973} 10974 10975func (s *RetryLayerUserStore) GetProfilesByUsernames(usernames []string, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error) { 10976 10977 tries := 0 10978 for { 10979 result, err := s.UserStore.GetProfilesByUsernames(usernames, viewRestrictions) 10980 if err == nil { 10981 return result, nil 10982 } 10983 if !isRepeatableError(err) { 10984 return result, err 10985 } 10986 tries++ 10987 if tries >= 3 { 10988 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 10989 return result, err 10990 } 10991 } 10992 10993} 10994 10995func (s *RetryLayerUserStore) GetProfilesInChannel(options *model.UserGetOptions) ([]*model.User, error) { 10996 10997 tries := 0 10998 for { 10999 result, err := s.UserStore.GetProfilesInChannel(options) 11000 if err == nil { 11001 return result, nil 11002 } 11003 if !isRepeatableError(err) { 11004 return result, err 11005 } 11006 tries++ 11007 if tries >= 3 { 11008 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11009 return result, err 11010 } 11011 } 11012 11013} 11014 11015func (s *RetryLayerUserStore) GetProfilesInChannelByStatus(options *model.UserGetOptions) ([]*model.User, error) { 11016 11017 tries := 0 11018 for { 11019 result, err := s.UserStore.GetProfilesInChannelByStatus(options) 11020 if err == nil { 11021 return result, nil 11022 } 11023 if !isRepeatableError(err) { 11024 return result, err 11025 } 11026 tries++ 11027 if tries >= 3 { 11028 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11029 return result, err 11030 } 11031 } 11032 11033} 11034 11035func (s *RetryLayerUserStore) GetProfilesNotInChannel(teamID string, channelId string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error) { 11036 11037 tries := 0 11038 for { 11039 result, err := s.UserStore.GetProfilesNotInChannel(teamID, channelId, groupConstrained, offset, limit, viewRestrictions) 11040 if err == nil { 11041 return result, nil 11042 } 11043 if !isRepeatableError(err) { 11044 return result, err 11045 } 11046 tries++ 11047 if tries >= 3 { 11048 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11049 return result, err 11050 } 11051 } 11052 11053} 11054 11055func (s *RetryLayerUserStore) GetProfilesNotInTeam(teamID string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error) { 11056 11057 tries := 0 11058 for { 11059 result, err := s.UserStore.GetProfilesNotInTeam(teamID, groupConstrained, offset, limit, viewRestrictions) 11060 if err == nil { 11061 return result, nil 11062 } 11063 if !isRepeatableError(err) { 11064 return result, err 11065 } 11066 tries++ 11067 if tries >= 3 { 11068 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11069 return result, err 11070 } 11071 } 11072 11073} 11074 11075func (s *RetryLayerUserStore) GetProfilesWithoutTeam(options *model.UserGetOptions) ([]*model.User, error) { 11076 11077 tries := 0 11078 for { 11079 result, err := s.UserStore.GetProfilesWithoutTeam(options) 11080 if err == nil { 11081 return result, nil 11082 } 11083 if !isRepeatableError(err) { 11084 return result, err 11085 } 11086 tries++ 11087 if tries >= 3 { 11088 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11089 return result, err 11090 } 11091 } 11092 11093} 11094 11095func (s *RetryLayerUserStore) GetRecentlyActiveUsersForTeam(teamID string, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error) { 11096 11097 tries := 0 11098 for { 11099 result, err := s.UserStore.GetRecentlyActiveUsersForTeam(teamID, offset, limit, viewRestrictions) 11100 if err == nil { 11101 return result, nil 11102 } 11103 if !isRepeatableError(err) { 11104 return result, err 11105 } 11106 tries++ 11107 if tries >= 3 { 11108 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11109 return result, err 11110 } 11111 } 11112 11113} 11114 11115func (s *RetryLayerUserStore) GetSystemAdminProfiles() (map[string]*model.User, error) { 11116 11117 tries := 0 11118 for { 11119 result, err := s.UserStore.GetSystemAdminProfiles() 11120 if err == nil { 11121 return result, nil 11122 } 11123 if !isRepeatableError(err) { 11124 return result, err 11125 } 11126 tries++ 11127 if tries >= 3 { 11128 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11129 return result, err 11130 } 11131 } 11132 11133} 11134 11135func (s *RetryLayerUserStore) GetTeamGroupUsers(teamID string) ([]*model.User, error) { 11136 11137 tries := 0 11138 for { 11139 result, err := s.UserStore.GetTeamGroupUsers(teamID) 11140 if err == nil { 11141 return result, nil 11142 } 11143 if !isRepeatableError(err) { 11144 return result, err 11145 } 11146 tries++ 11147 if tries >= 3 { 11148 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11149 return result, err 11150 } 11151 } 11152 11153} 11154 11155func (s *RetryLayerUserStore) GetUnreadCount(userID string) (int64, error) { 11156 11157 tries := 0 11158 for { 11159 result, err := s.UserStore.GetUnreadCount(userID) 11160 if err == nil { 11161 return result, nil 11162 } 11163 if !isRepeatableError(err) { 11164 return result, err 11165 } 11166 tries++ 11167 if tries >= 3 { 11168 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11169 return result, err 11170 } 11171 } 11172 11173} 11174 11175func (s *RetryLayerUserStore) GetUnreadCountForChannel(userID string, channelID string) (int64, error) { 11176 11177 tries := 0 11178 for { 11179 result, err := s.UserStore.GetUnreadCountForChannel(userID, channelID) 11180 if err == nil { 11181 return result, nil 11182 } 11183 if !isRepeatableError(err) { 11184 return result, err 11185 } 11186 tries++ 11187 if tries >= 3 { 11188 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11189 return result, err 11190 } 11191 } 11192 11193} 11194 11195func (s *RetryLayerUserStore) GetUsersBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.UserForIndexing, error) { 11196 11197 tries := 0 11198 for { 11199 result, err := s.UserStore.GetUsersBatchForIndexing(startTime, endTime, limit) 11200 if err == nil { 11201 return result, nil 11202 } 11203 if !isRepeatableError(err) { 11204 return result, err 11205 } 11206 tries++ 11207 if tries >= 3 { 11208 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11209 return result, err 11210 } 11211 } 11212 11213} 11214 11215func (s *RetryLayerUserStore) InferSystemInstallDate() (int64, error) { 11216 11217 tries := 0 11218 for { 11219 result, err := s.UserStore.InferSystemInstallDate() 11220 if err == nil { 11221 return result, nil 11222 } 11223 if !isRepeatableError(err) { 11224 return result, err 11225 } 11226 tries++ 11227 if tries >= 3 { 11228 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11229 return result, err 11230 } 11231 } 11232 11233} 11234 11235func (s *RetryLayerUserStore) InvalidateProfileCacheForUser(userID string) { 11236 11237 s.UserStore.InvalidateProfileCacheForUser(userID) 11238 11239} 11240 11241func (s *RetryLayerUserStore) InvalidateProfilesInChannelCache(channelID string) { 11242 11243 s.UserStore.InvalidateProfilesInChannelCache(channelID) 11244 11245} 11246 11247func (s *RetryLayerUserStore) InvalidateProfilesInChannelCacheByUser(userID string) { 11248 11249 s.UserStore.InvalidateProfilesInChannelCacheByUser(userID) 11250 11251} 11252 11253func (s *RetryLayerUserStore) IsEmpty(excludeBots bool) (bool, error) { 11254 11255 tries := 0 11256 for { 11257 result, err := s.UserStore.IsEmpty(excludeBots) 11258 if err == nil { 11259 return result, nil 11260 } 11261 if !isRepeatableError(err) { 11262 return result, err 11263 } 11264 tries++ 11265 if tries >= 3 { 11266 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11267 return result, err 11268 } 11269 } 11270 11271} 11272 11273func (s *RetryLayerUserStore) PermanentDelete(userID string) error { 11274 11275 tries := 0 11276 for { 11277 err := s.UserStore.PermanentDelete(userID) 11278 if err == nil { 11279 return nil 11280 } 11281 if !isRepeatableError(err) { 11282 return err 11283 } 11284 tries++ 11285 if tries >= 3 { 11286 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11287 return err 11288 } 11289 } 11290 11291} 11292 11293func (s *RetryLayerUserStore) PromoteGuestToUser(userID string) error { 11294 11295 tries := 0 11296 for { 11297 err := s.UserStore.PromoteGuestToUser(userID) 11298 if err == nil { 11299 return nil 11300 } 11301 if !isRepeatableError(err) { 11302 return err 11303 } 11304 tries++ 11305 if tries >= 3 { 11306 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11307 return err 11308 } 11309 } 11310 11311} 11312 11313func (s *RetryLayerUserStore) ResetAuthDataToEmailForUsers(service string, userIDs []string, includeDeleted bool, dryRun bool) (int, error) { 11314 11315 tries := 0 11316 for { 11317 result, err := s.UserStore.ResetAuthDataToEmailForUsers(service, userIDs, includeDeleted, dryRun) 11318 if err == nil { 11319 return result, nil 11320 } 11321 if !isRepeatableError(err) { 11322 return result, err 11323 } 11324 tries++ 11325 if tries >= 3 { 11326 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11327 return result, err 11328 } 11329 } 11330 11331} 11332 11333func (s *RetryLayerUserStore) ResetLastPictureUpdate(userID string) error { 11334 11335 tries := 0 11336 for { 11337 err := s.UserStore.ResetLastPictureUpdate(userID) 11338 if err == nil { 11339 return nil 11340 } 11341 if !isRepeatableError(err) { 11342 return err 11343 } 11344 tries++ 11345 if tries >= 3 { 11346 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11347 return err 11348 } 11349 } 11350 11351} 11352 11353func (s *RetryLayerUserStore) Save(user *model.User) (*model.User, error) { 11354 11355 tries := 0 11356 for { 11357 result, err := s.UserStore.Save(user) 11358 if err == nil { 11359 return result, nil 11360 } 11361 if !isRepeatableError(err) { 11362 return result, err 11363 } 11364 tries++ 11365 if tries >= 3 { 11366 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11367 return result, err 11368 } 11369 } 11370 11371} 11372 11373func (s *RetryLayerUserStore) Search(teamID string, term string, options *model.UserSearchOptions) ([]*model.User, error) { 11374 11375 tries := 0 11376 for { 11377 result, err := s.UserStore.Search(teamID, term, options) 11378 if err == nil { 11379 return result, nil 11380 } 11381 if !isRepeatableError(err) { 11382 return result, err 11383 } 11384 tries++ 11385 if tries >= 3 { 11386 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11387 return result, err 11388 } 11389 } 11390 11391} 11392 11393func (s *RetryLayerUserStore) SearchInChannel(channelID string, term string, options *model.UserSearchOptions) ([]*model.User, error) { 11394 11395 tries := 0 11396 for { 11397 result, err := s.UserStore.SearchInChannel(channelID, term, options) 11398 if err == nil { 11399 return result, nil 11400 } 11401 if !isRepeatableError(err) { 11402 return result, err 11403 } 11404 tries++ 11405 if tries >= 3 { 11406 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11407 return result, err 11408 } 11409 } 11410 11411} 11412 11413func (s *RetryLayerUserStore) SearchInGroup(groupID string, term string, options *model.UserSearchOptions) ([]*model.User, error) { 11414 11415 tries := 0 11416 for { 11417 result, err := s.UserStore.SearchInGroup(groupID, term, options) 11418 if err == nil { 11419 return result, nil 11420 } 11421 if !isRepeatableError(err) { 11422 return result, err 11423 } 11424 tries++ 11425 if tries >= 3 { 11426 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11427 return result, err 11428 } 11429 } 11430 11431} 11432 11433func (s *RetryLayerUserStore) SearchNotInChannel(teamID string, channelID string, term string, options *model.UserSearchOptions) ([]*model.User, error) { 11434 11435 tries := 0 11436 for { 11437 result, err := s.UserStore.SearchNotInChannel(teamID, channelID, term, options) 11438 if err == nil { 11439 return result, nil 11440 } 11441 if !isRepeatableError(err) { 11442 return result, err 11443 } 11444 tries++ 11445 if tries >= 3 { 11446 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11447 return result, err 11448 } 11449 } 11450 11451} 11452 11453func (s *RetryLayerUserStore) SearchNotInTeam(notInTeamID string, term string, options *model.UserSearchOptions) ([]*model.User, error) { 11454 11455 tries := 0 11456 for { 11457 result, err := s.UserStore.SearchNotInTeam(notInTeamID, term, options) 11458 if err == nil { 11459 return result, nil 11460 } 11461 if !isRepeatableError(err) { 11462 return result, err 11463 } 11464 tries++ 11465 if tries >= 3 { 11466 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11467 return result, err 11468 } 11469 } 11470 11471} 11472 11473func (s *RetryLayerUserStore) SearchWithoutTeam(term string, options *model.UserSearchOptions) ([]*model.User, error) { 11474 11475 tries := 0 11476 for { 11477 result, err := s.UserStore.SearchWithoutTeam(term, options) 11478 if err == nil { 11479 return result, nil 11480 } 11481 if !isRepeatableError(err) { 11482 return result, err 11483 } 11484 tries++ 11485 if tries >= 3 { 11486 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11487 return result, err 11488 } 11489 } 11490 11491} 11492 11493func (s *RetryLayerUserStore) Update(user *model.User, allowRoleUpdate bool) (*model.UserUpdate, error) { 11494 11495 tries := 0 11496 for { 11497 result, err := s.UserStore.Update(user, allowRoleUpdate) 11498 if err == nil { 11499 return result, nil 11500 } 11501 if !isRepeatableError(err) { 11502 return result, err 11503 } 11504 tries++ 11505 if tries >= 3 { 11506 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11507 return result, err 11508 } 11509 } 11510 11511} 11512 11513func (s *RetryLayerUserStore) UpdateAuthData(userID string, service string, authData *string, email string, resetMfa bool) (string, error) { 11514 11515 tries := 0 11516 for { 11517 result, err := s.UserStore.UpdateAuthData(userID, service, authData, email, resetMfa) 11518 if err == nil { 11519 return result, nil 11520 } 11521 if !isRepeatableError(err) { 11522 return result, err 11523 } 11524 tries++ 11525 if tries >= 3 { 11526 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11527 return result, err 11528 } 11529 } 11530 11531} 11532 11533func (s *RetryLayerUserStore) UpdateFailedPasswordAttempts(userID string, attempts int) error { 11534 11535 tries := 0 11536 for { 11537 err := s.UserStore.UpdateFailedPasswordAttempts(userID, attempts) 11538 if err == nil { 11539 return nil 11540 } 11541 if !isRepeatableError(err) { 11542 return err 11543 } 11544 tries++ 11545 if tries >= 3 { 11546 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11547 return err 11548 } 11549 } 11550 11551} 11552 11553func (s *RetryLayerUserStore) UpdateLastPictureUpdate(userID string) error { 11554 11555 tries := 0 11556 for { 11557 err := s.UserStore.UpdateLastPictureUpdate(userID) 11558 if err == nil { 11559 return nil 11560 } 11561 if !isRepeatableError(err) { 11562 return err 11563 } 11564 tries++ 11565 if tries >= 3 { 11566 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11567 return err 11568 } 11569 } 11570 11571} 11572 11573func (s *RetryLayerUserStore) UpdateMfaActive(userID string, active bool) error { 11574 11575 tries := 0 11576 for { 11577 err := s.UserStore.UpdateMfaActive(userID, active) 11578 if err == nil { 11579 return nil 11580 } 11581 if !isRepeatableError(err) { 11582 return err 11583 } 11584 tries++ 11585 if tries >= 3 { 11586 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11587 return err 11588 } 11589 } 11590 11591} 11592 11593func (s *RetryLayerUserStore) UpdateMfaSecret(userID string, secret string) error { 11594 11595 tries := 0 11596 for { 11597 err := s.UserStore.UpdateMfaSecret(userID, secret) 11598 if err == nil { 11599 return nil 11600 } 11601 if !isRepeatableError(err) { 11602 return err 11603 } 11604 tries++ 11605 if tries >= 3 { 11606 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11607 return err 11608 } 11609 } 11610 11611} 11612 11613func (s *RetryLayerUserStore) UpdateNotifyProps(userID string, props map[string]string) error { 11614 11615 tries := 0 11616 for { 11617 err := s.UserStore.UpdateNotifyProps(userID, props) 11618 if err == nil { 11619 return nil 11620 } 11621 if !isRepeatableError(err) { 11622 return err 11623 } 11624 tries++ 11625 if tries >= 3 { 11626 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11627 return err 11628 } 11629 } 11630 11631} 11632 11633func (s *RetryLayerUserStore) UpdatePassword(userID string, newPassword string) error { 11634 11635 tries := 0 11636 for { 11637 err := s.UserStore.UpdatePassword(userID, newPassword) 11638 if err == nil { 11639 return nil 11640 } 11641 if !isRepeatableError(err) { 11642 return err 11643 } 11644 tries++ 11645 if tries >= 3 { 11646 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11647 return err 11648 } 11649 } 11650 11651} 11652 11653func (s *RetryLayerUserStore) UpdateUpdateAt(userID string) (int64, error) { 11654 11655 tries := 0 11656 for { 11657 result, err := s.UserStore.UpdateUpdateAt(userID) 11658 if err == nil { 11659 return result, nil 11660 } 11661 if !isRepeatableError(err) { 11662 return result, err 11663 } 11664 tries++ 11665 if tries >= 3 { 11666 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11667 return result, err 11668 } 11669 } 11670 11671} 11672 11673func (s *RetryLayerUserStore) VerifyEmail(userID string, email string) (string, error) { 11674 11675 tries := 0 11676 for { 11677 result, err := s.UserStore.VerifyEmail(userID, email) 11678 if err == nil { 11679 return result, nil 11680 } 11681 if !isRepeatableError(err) { 11682 return result, err 11683 } 11684 tries++ 11685 if tries >= 3 { 11686 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11687 return result, err 11688 } 11689 } 11690 11691} 11692 11693func (s *RetryLayerUserAccessTokenStore) Delete(tokenID string) error { 11694 11695 tries := 0 11696 for { 11697 err := s.UserAccessTokenStore.Delete(tokenID) 11698 if err == nil { 11699 return nil 11700 } 11701 if !isRepeatableError(err) { 11702 return err 11703 } 11704 tries++ 11705 if tries >= 3 { 11706 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11707 return err 11708 } 11709 } 11710 11711} 11712 11713func (s *RetryLayerUserAccessTokenStore) DeleteAllForUser(userID string) error { 11714 11715 tries := 0 11716 for { 11717 err := s.UserAccessTokenStore.DeleteAllForUser(userID) 11718 if err == nil { 11719 return nil 11720 } 11721 if !isRepeatableError(err) { 11722 return err 11723 } 11724 tries++ 11725 if tries >= 3 { 11726 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11727 return err 11728 } 11729 } 11730 11731} 11732 11733func (s *RetryLayerUserAccessTokenStore) Get(tokenID string) (*model.UserAccessToken, error) { 11734 11735 tries := 0 11736 for { 11737 result, err := s.UserAccessTokenStore.Get(tokenID) 11738 if err == nil { 11739 return result, nil 11740 } 11741 if !isRepeatableError(err) { 11742 return result, err 11743 } 11744 tries++ 11745 if tries >= 3 { 11746 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11747 return result, err 11748 } 11749 } 11750 11751} 11752 11753func (s *RetryLayerUserAccessTokenStore) GetAll(offset int, limit int) ([]*model.UserAccessToken, error) { 11754 11755 tries := 0 11756 for { 11757 result, err := s.UserAccessTokenStore.GetAll(offset, limit) 11758 if err == nil { 11759 return result, nil 11760 } 11761 if !isRepeatableError(err) { 11762 return result, err 11763 } 11764 tries++ 11765 if tries >= 3 { 11766 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11767 return result, err 11768 } 11769 } 11770 11771} 11772 11773func (s *RetryLayerUserAccessTokenStore) GetByToken(tokenString string) (*model.UserAccessToken, error) { 11774 11775 tries := 0 11776 for { 11777 result, err := s.UserAccessTokenStore.GetByToken(tokenString) 11778 if err == nil { 11779 return result, nil 11780 } 11781 if !isRepeatableError(err) { 11782 return result, err 11783 } 11784 tries++ 11785 if tries >= 3 { 11786 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11787 return result, err 11788 } 11789 } 11790 11791} 11792 11793func (s *RetryLayerUserAccessTokenStore) GetByUser(userID string, page int, perPage int) ([]*model.UserAccessToken, error) { 11794 11795 tries := 0 11796 for { 11797 result, err := s.UserAccessTokenStore.GetByUser(userID, page, perPage) 11798 if err == nil { 11799 return result, nil 11800 } 11801 if !isRepeatableError(err) { 11802 return result, err 11803 } 11804 tries++ 11805 if tries >= 3 { 11806 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11807 return result, err 11808 } 11809 } 11810 11811} 11812 11813func (s *RetryLayerUserAccessTokenStore) Save(token *model.UserAccessToken) (*model.UserAccessToken, error) { 11814 11815 tries := 0 11816 for { 11817 result, err := s.UserAccessTokenStore.Save(token) 11818 if err == nil { 11819 return result, nil 11820 } 11821 if !isRepeatableError(err) { 11822 return result, err 11823 } 11824 tries++ 11825 if tries >= 3 { 11826 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11827 return result, err 11828 } 11829 } 11830 11831} 11832 11833func (s *RetryLayerUserAccessTokenStore) Search(term string) ([]*model.UserAccessToken, error) { 11834 11835 tries := 0 11836 for { 11837 result, err := s.UserAccessTokenStore.Search(term) 11838 if err == nil { 11839 return result, nil 11840 } 11841 if !isRepeatableError(err) { 11842 return result, err 11843 } 11844 tries++ 11845 if tries >= 3 { 11846 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11847 return result, err 11848 } 11849 } 11850 11851} 11852 11853func (s *RetryLayerUserAccessTokenStore) UpdateTokenDisable(tokenID string) error { 11854 11855 tries := 0 11856 for { 11857 err := s.UserAccessTokenStore.UpdateTokenDisable(tokenID) 11858 if err == nil { 11859 return nil 11860 } 11861 if !isRepeatableError(err) { 11862 return err 11863 } 11864 tries++ 11865 if tries >= 3 { 11866 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11867 return err 11868 } 11869 } 11870 11871} 11872 11873func (s *RetryLayerUserAccessTokenStore) UpdateTokenEnable(tokenID string) error { 11874 11875 tries := 0 11876 for { 11877 err := s.UserAccessTokenStore.UpdateTokenEnable(tokenID) 11878 if err == nil { 11879 return nil 11880 } 11881 if !isRepeatableError(err) { 11882 return err 11883 } 11884 tries++ 11885 if tries >= 3 { 11886 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11887 return err 11888 } 11889 } 11890 11891} 11892 11893func (s *RetryLayerUserTermsOfServiceStore) Delete(userID string, termsOfServiceId string) error { 11894 11895 tries := 0 11896 for { 11897 err := s.UserTermsOfServiceStore.Delete(userID, termsOfServiceId) 11898 if err == nil { 11899 return nil 11900 } 11901 if !isRepeatableError(err) { 11902 return err 11903 } 11904 tries++ 11905 if tries >= 3 { 11906 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11907 return err 11908 } 11909 } 11910 11911} 11912 11913func (s *RetryLayerUserTermsOfServiceStore) GetByUser(userID string) (*model.UserTermsOfService, error) { 11914 11915 tries := 0 11916 for { 11917 result, err := s.UserTermsOfServiceStore.GetByUser(userID) 11918 if err == nil { 11919 return result, nil 11920 } 11921 if !isRepeatableError(err) { 11922 return result, err 11923 } 11924 tries++ 11925 if tries >= 3 { 11926 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11927 return result, err 11928 } 11929 } 11930 11931} 11932 11933func (s *RetryLayerUserTermsOfServiceStore) Save(userTermsOfService *model.UserTermsOfService) (*model.UserTermsOfService, error) { 11934 11935 tries := 0 11936 for { 11937 result, err := s.UserTermsOfServiceStore.Save(userTermsOfService) 11938 if err == nil { 11939 return result, nil 11940 } 11941 if !isRepeatableError(err) { 11942 return result, err 11943 } 11944 tries++ 11945 if tries >= 3 { 11946 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11947 return result, err 11948 } 11949 } 11950 11951} 11952 11953func (s *RetryLayerWebhookStore) AnalyticsIncomingCount(teamID string) (int64, error) { 11954 11955 tries := 0 11956 for { 11957 result, err := s.WebhookStore.AnalyticsIncomingCount(teamID) 11958 if err == nil { 11959 return result, nil 11960 } 11961 if !isRepeatableError(err) { 11962 return result, err 11963 } 11964 tries++ 11965 if tries >= 3 { 11966 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11967 return result, err 11968 } 11969 } 11970 11971} 11972 11973func (s *RetryLayerWebhookStore) AnalyticsOutgoingCount(teamID string) (int64, error) { 11974 11975 tries := 0 11976 for { 11977 result, err := s.WebhookStore.AnalyticsOutgoingCount(teamID) 11978 if err == nil { 11979 return result, nil 11980 } 11981 if !isRepeatableError(err) { 11982 return result, err 11983 } 11984 tries++ 11985 if tries >= 3 { 11986 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 11987 return result, err 11988 } 11989 } 11990 11991} 11992 11993func (s *RetryLayerWebhookStore) ClearCaches() { 11994 11995 s.WebhookStore.ClearCaches() 11996 11997} 11998 11999func (s *RetryLayerWebhookStore) DeleteIncoming(webhookID string, time int64) error { 12000 12001 tries := 0 12002 for { 12003 err := s.WebhookStore.DeleteIncoming(webhookID, time) 12004 if err == nil { 12005 return nil 12006 } 12007 if !isRepeatableError(err) { 12008 return err 12009 } 12010 tries++ 12011 if tries >= 3 { 12012 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 12013 return err 12014 } 12015 } 12016 12017} 12018 12019func (s *RetryLayerWebhookStore) DeleteOutgoing(webhookID string, time int64) error { 12020 12021 tries := 0 12022 for { 12023 err := s.WebhookStore.DeleteOutgoing(webhookID, time) 12024 if err == nil { 12025 return nil 12026 } 12027 if !isRepeatableError(err) { 12028 return err 12029 } 12030 tries++ 12031 if tries >= 3 { 12032 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 12033 return err 12034 } 12035 } 12036 12037} 12038 12039func (s *RetryLayerWebhookStore) GetIncoming(id string, allowFromCache bool) (*model.IncomingWebhook, error) { 12040 12041 tries := 0 12042 for { 12043 result, err := s.WebhookStore.GetIncoming(id, allowFromCache) 12044 if err == nil { 12045 return result, nil 12046 } 12047 if !isRepeatableError(err) { 12048 return result, err 12049 } 12050 tries++ 12051 if tries >= 3 { 12052 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 12053 return result, err 12054 } 12055 } 12056 12057} 12058 12059func (s *RetryLayerWebhookStore) GetIncomingByChannel(channelID string) ([]*model.IncomingWebhook, error) { 12060 12061 tries := 0 12062 for { 12063 result, err := s.WebhookStore.GetIncomingByChannel(channelID) 12064 if err == nil { 12065 return result, nil 12066 } 12067 if !isRepeatableError(err) { 12068 return result, err 12069 } 12070 tries++ 12071 if tries >= 3 { 12072 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 12073 return result, err 12074 } 12075 } 12076 12077} 12078 12079func (s *RetryLayerWebhookStore) GetIncomingByTeam(teamID string, offset int, limit int) ([]*model.IncomingWebhook, error) { 12080 12081 tries := 0 12082 for { 12083 result, err := s.WebhookStore.GetIncomingByTeam(teamID, offset, limit) 12084 if err == nil { 12085 return result, nil 12086 } 12087 if !isRepeatableError(err) { 12088 return result, err 12089 } 12090 tries++ 12091 if tries >= 3 { 12092 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 12093 return result, err 12094 } 12095 } 12096 12097} 12098 12099func (s *RetryLayerWebhookStore) GetIncomingByTeamByUser(teamID string, userID string, offset int, limit int) ([]*model.IncomingWebhook, error) { 12100 12101 tries := 0 12102 for { 12103 result, err := s.WebhookStore.GetIncomingByTeamByUser(teamID, userID, offset, limit) 12104 if err == nil { 12105 return result, nil 12106 } 12107 if !isRepeatableError(err) { 12108 return result, err 12109 } 12110 tries++ 12111 if tries >= 3 { 12112 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 12113 return result, err 12114 } 12115 } 12116 12117} 12118 12119func (s *RetryLayerWebhookStore) GetIncomingList(offset int, limit int) ([]*model.IncomingWebhook, error) { 12120 12121 tries := 0 12122 for { 12123 result, err := s.WebhookStore.GetIncomingList(offset, limit) 12124 if err == nil { 12125 return result, nil 12126 } 12127 if !isRepeatableError(err) { 12128 return result, err 12129 } 12130 tries++ 12131 if tries >= 3 { 12132 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 12133 return result, err 12134 } 12135 } 12136 12137} 12138 12139func (s *RetryLayerWebhookStore) GetIncomingListByUser(userID string, offset int, limit int) ([]*model.IncomingWebhook, error) { 12140 12141 tries := 0 12142 for { 12143 result, err := s.WebhookStore.GetIncomingListByUser(userID, offset, limit) 12144 if err == nil { 12145 return result, nil 12146 } 12147 if !isRepeatableError(err) { 12148 return result, err 12149 } 12150 tries++ 12151 if tries >= 3 { 12152 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 12153 return result, err 12154 } 12155 } 12156 12157} 12158 12159func (s *RetryLayerWebhookStore) GetOutgoing(id string) (*model.OutgoingWebhook, error) { 12160 12161 tries := 0 12162 for { 12163 result, err := s.WebhookStore.GetOutgoing(id) 12164 if err == nil { 12165 return result, nil 12166 } 12167 if !isRepeatableError(err) { 12168 return result, err 12169 } 12170 tries++ 12171 if tries >= 3 { 12172 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 12173 return result, err 12174 } 12175 } 12176 12177} 12178 12179func (s *RetryLayerWebhookStore) GetOutgoingByChannel(channelID string, offset int, limit int) ([]*model.OutgoingWebhook, error) { 12180 12181 tries := 0 12182 for { 12183 result, err := s.WebhookStore.GetOutgoingByChannel(channelID, offset, limit) 12184 if err == nil { 12185 return result, nil 12186 } 12187 if !isRepeatableError(err) { 12188 return result, err 12189 } 12190 tries++ 12191 if tries >= 3 { 12192 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 12193 return result, err 12194 } 12195 } 12196 12197} 12198 12199func (s *RetryLayerWebhookStore) GetOutgoingByChannelByUser(channelID string, userID string, offset int, limit int) ([]*model.OutgoingWebhook, error) { 12200 12201 tries := 0 12202 for { 12203 result, err := s.WebhookStore.GetOutgoingByChannelByUser(channelID, userID, offset, limit) 12204 if err == nil { 12205 return result, nil 12206 } 12207 if !isRepeatableError(err) { 12208 return result, err 12209 } 12210 tries++ 12211 if tries >= 3 { 12212 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 12213 return result, err 12214 } 12215 } 12216 12217} 12218 12219func (s *RetryLayerWebhookStore) GetOutgoingByTeam(teamID string, offset int, limit int) ([]*model.OutgoingWebhook, error) { 12220 12221 tries := 0 12222 for { 12223 result, err := s.WebhookStore.GetOutgoingByTeam(teamID, offset, limit) 12224 if err == nil { 12225 return result, nil 12226 } 12227 if !isRepeatableError(err) { 12228 return result, err 12229 } 12230 tries++ 12231 if tries >= 3 { 12232 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 12233 return result, err 12234 } 12235 } 12236 12237} 12238 12239func (s *RetryLayerWebhookStore) GetOutgoingByTeamByUser(teamID string, userID string, offset int, limit int) ([]*model.OutgoingWebhook, error) { 12240 12241 tries := 0 12242 for { 12243 result, err := s.WebhookStore.GetOutgoingByTeamByUser(teamID, userID, offset, limit) 12244 if err == nil { 12245 return result, nil 12246 } 12247 if !isRepeatableError(err) { 12248 return result, err 12249 } 12250 tries++ 12251 if tries >= 3 { 12252 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 12253 return result, err 12254 } 12255 } 12256 12257} 12258 12259func (s *RetryLayerWebhookStore) GetOutgoingList(offset int, limit int) ([]*model.OutgoingWebhook, error) { 12260 12261 tries := 0 12262 for { 12263 result, err := s.WebhookStore.GetOutgoingList(offset, limit) 12264 if err == nil { 12265 return result, nil 12266 } 12267 if !isRepeatableError(err) { 12268 return result, err 12269 } 12270 tries++ 12271 if tries >= 3 { 12272 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 12273 return result, err 12274 } 12275 } 12276 12277} 12278 12279func (s *RetryLayerWebhookStore) GetOutgoingListByUser(userID string, offset int, limit int) ([]*model.OutgoingWebhook, error) { 12280 12281 tries := 0 12282 for { 12283 result, err := s.WebhookStore.GetOutgoingListByUser(userID, offset, limit) 12284 if err == nil { 12285 return result, nil 12286 } 12287 if !isRepeatableError(err) { 12288 return result, err 12289 } 12290 tries++ 12291 if tries >= 3 { 12292 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 12293 return result, err 12294 } 12295 } 12296 12297} 12298 12299func (s *RetryLayerWebhookStore) InvalidateWebhookCache(webhook string) { 12300 12301 s.WebhookStore.InvalidateWebhookCache(webhook) 12302 12303} 12304 12305func (s *RetryLayerWebhookStore) PermanentDeleteIncomingByChannel(channelID string) error { 12306 12307 tries := 0 12308 for { 12309 err := s.WebhookStore.PermanentDeleteIncomingByChannel(channelID) 12310 if err == nil { 12311 return nil 12312 } 12313 if !isRepeatableError(err) { 12314 return err 12315 } 12316 tries++ 12317 if tries >= 3 { 12318 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 12319 return err 12320 } 12321 } 12322 12323} 12324 12325func (s *RetryLayerWebhookStore) PermanentDeleteIncomingByUser(userID string) error { 12326 12327 tries := 0 12328 for { 12329 err := s.WebhookStore.PermanentDeleteIncomingByUser(userID) 12330 if err == nil { 12331 return nil 12332 } 12333 if !isRepeatableError(err) { 12334 return err 12335 } 12336 tries++ 12337 if tries >= 3 { 12338 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 12339 return err 12340 } 12341 } 12342 12343} 12344 12345func (s *RetryLayerWebhookStore) PermanentDeleteOutgoingByChannel(channelID string) error { 12346 12347 tries := 0 12348 for { 12349 err := s.WebhookStore.PermanentDeleteOutgoingByChannel(channelID) 12350 if err == nil { 12351 return nil 12352 } 12353 if !isRepeatableError(err) { 12354 return err 12355 } 12356 tries++ 12357 if tries >= 3 { 12358 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 12359 return err 12360 } 12361 } 12362 12363} 12364 12365func (s *RetryLayerWebhookStore) PermanentDeleteOutgoingByUser(userID string) error { 12366 12367 tries := 0 12368 for { 12369 err := s.WebhookStore.PermanentDeleteOutgoingByUser(userID) 12370 if err == nil { 12371 return nil 12372 } 12373 if !isRepeatableError(err) { 12374 return err 12375 } 12376 tries++ 12377 if tries >= 3 { 12378 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 12379 return err 12380 } 12381 } 12382 12383} 12384 12385func (s *RetryLayerWebhookStore) SaveIncoming(webhook *model.IncomingWebhook) (*model.IncomingWebhook, error) { 12386 12387 tries := 0 12388 for { 12389 result, err := s.WebhookStore.SaveIncoming(webhook) 12390 if err == nil { 12391 return result, nil 12392 } 12393 if !isRepeatableError(err) { 12394 return result, err 12395 } 12396 tries++ 12397 if tries >= 3 { 12398 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 12399 return result, err 12400 } 12401 } 12402 12403} 12404 12405func (s *RetryLayerWebhookStore) SaveOutgoing(webhook *model.OutgoingWebhook) (*model.OutgoingWebhook, error) { 12406 12407 tries := 0 12408 for { 12409 result, err := s.WebhookStore.SaveOutgoing(webhook) 12410 if err == nil { 12411 return result, nil 12412 } 12413 if !isRepeatableError(err) { 12414 return result, err 12415 } 12416 tries++ 12417 if tries >= 3 { 12418 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 12419 return result, err 12420 } 12421 } 12422 12423} 12424 12425func (s *RetryLayerWebhookStore) UpdateIncoming(webhook *model.IncomingWebhook) (*model.IncomingWebhook, error) { 12426 12427 tries := 0 12428 for { 12429 result, err := s.WebhookStore.UpdateIncoming(webhook) 12430 if err == nil { 12431 return result, nil 12432 } 12433 if !isRepeatableError(err) { 12434 return result, err 12435 } 12436 tries++ 12437 if tries >= 3 { 12438 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 12439 return result, err 12440 } 12441 } 12442 12443} 12444 12445func (s *RetryLayerWebhookStore) UpdateOutgoing(hook *model.OutgoingWebhook) (*model.OutgoingWebhook, error) { 12446 12447 tries := 0 12448 for { 12449 result, err := s.WebhookStore.UpdateOutgoing(hook) 12450 if err == nil { 12451 return result, nil 12452 } 12453 if !isRepeatableError(err) { 12454 return result, err 12455 } 12456 tries++ 12457 if tries >= 3 { 12458 err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures") 12459 return result, err 12460 } 12461 } 12462 12463} 12464 12465func (s *RetryLayer) Close() { 12466 s.Store.Close() 12467} 12468 12469func (s *RetryLayer) DropAllTables() { 12470 s.Store.DropAllTables() 12471} 12472 12473func (s *RetryLayer) GetCurrentSchemaVersion() string { 12474 return s.Store.GetCurrentSchemaVersion() 12475} 12476 12477func (s *RetryLayer) LockToMaster() { 12478 s.Store.LockToMaster() 12479} 12480 12481func (s *RetryLayer) MarkSystemRanUnitTests() { 12482 s.Store.MarkSystemRanUnitTests() 12483} 12484 12485func (s *RetryLayer) SetContext(context context.Context) { 12486 s.Store.SetContext(context) 12487} 12488 12489func (s *RetryLayer) TotalMasterDbConnections() int { 12490 return s.Store.TotalMasterDbConnections() 12491} 12492 12493func (s *RetryLayer) TotalReadDbConnections() int { 12494 return s.Store.TotalReadDbConnections() 12495} 12496 12497func (s *RetryLayer) TotalSearchDbConnections() int { 12498 return s.Store.TotalSearchDbConnections() 12499} 12500 12501func (s *RetryLayer) UnlockFromMaster() { 12502 s.Store.UnlockFromMaster() 12503} 12504 12505func New(childStore store.Store) *RetryLayer { 12506 newStore := RetryLayer{ 12507 Store: childStore, 12508 } 12509 12510 newStore.AuditStore = &RetryLayerAuditStore{AuditStore: childStore.Audit(), Root: &newStore} 12511 newStore.BotStore = &RetryLayerBotStore{BotStore: childStore.Bot(), Root: &newStore} 12512 newStore.ChannelStore = &RetryLayerChannelStore{ChannelStore: childStore.Channel(), Root: &newStore} 12513 newStore.ChannelMemberHistoryStore = &RetryLayerChannelMemberHistoryStore{ChannelMemberHistoryStore: childStore.ChannelMemberHistory(), Root: &newStore} 12514 newStore.ClusterDiscoveryStore = &RetryLayerClusterDiscoveryStore{ClusterDiscoveryStore: childStore.ClusterDiscovery(), Root: &newStore} 12515 newStore.CommandStore = &RetryLayerCommandStore{CommandStore: childStore.Command(), Root: &newStore} 12516 newStore.CommandWebhookStore = &RetryLayerCommandWebhookStore{CommandWebhookStore: childStore.CommandWebhook(), Root: &newStore} 12517 newStore.ComplianceStore = &RetryLayerComplianceStore{ComplianceStore: childStore.Compliance(), Root: &newStore} 12518 newStore.EmojiStore = &RetryLayerEmojiStore{EmojiStore: childStore.Emoji(), Root: &newStore} 12519 newStore.FileInfoStore = &RetryLayerFileInfoStore{FileInfoStore: childStore.FileInfo(), Root: &newStore} 12520 newStore.GroupStore = &RetryLayerGroupStore{GroupStore: childStore.Group(), Root: &newStore} 12521 newStore.JobStore = &RetryLayerJobStore{JobStore: childStore.Job(), Root: &newStore} 12522 newStore.LicenseStore = &RetryLayerLicenseStore{LicenseStore: childStore.License(), Root: &newStore} 12523 newStore.LinkMetadataStore = &RetryLayerLinkMetadataStore{LinkMetadataStore: childStore.LinkMetadata(), Root: &newStore} 12524 newStore.OAuthStore = &RetryLayerOAuthStore{OAuthStore: childStore.OAuth(), Root: &newStore} 12525 newStore.PluginStore = &RetryLayerPluginStore{PluginStore: childStore.Plugin(), Root: &newStore} 12526 newStore.PostStore = &RetryLayerPostStore{PostStore: childStore.Post(), Root: &newStore} 12527 newStore.PreferenceStore = &RetryLayerPreferenceStore{PreferenceStore: childStore.Preference(), Root: &newStore} 12528 newStore.ProductNoticesStore = &RetryLayerProductNoticesStore{ProductNoticesStore: childStore.ProductNotices(), Root: &newStore} 12529 newStore.ReactionStore = &RetryLayerReactionStore{ReactionStore: childStore.Reaction(), Root: &newStore} 12530 newStore.RemoteClusterStore = &RetryLayerRemoteClusterStore{RemoteClusterStore: childStore.RemoteCluster(), Root: &newStore} 12531 newStore.RetentionPolicyStore = &RetryLayerRetentionPolicyStore{RetentionPolicyStore: childStore.RetentionPolicy(), Root: &newStore} 12532 newStore.RoleStore = &RetryLayerRoleStore{RoleStore: childStore.Role(), Root: &newStore} 12533 newStore.SchemeStore = &RetryLayerSchemeStore{SchemeStore: childStore.Scheme(), Root: &newStore} 12534 newStore.SessionStore = &RetryLayerSessionStore{SessionStore: childStore.Session(), Root: &newStore} 12535 newStore.SharedChannelStore = &RetryLayerSharedChannelStore{SharedChannelStore: childStore.SharedChannel(), Root: &newStore} 12536 newStore.StatusStore = &RetryLayerStatusStore{StatusStore: childStore.Status(), Root: &newStore} 12537 newStore.SystemStore = &RetryLayerSystemStore{SystemStore: childStore.System(), Root: &newStore} 12538 newStore.TeamStore = &RetryLayerTeamStore{TeamStore: childStore.Team(), Root: &newStore} 12539 newStore.TermsOfServiceStore = &RetryLayerTermsOfServiceStore{TermsOfServiceStore: childStore.TermsOfService(), Root: &newStore} 12540 newStore.ThreadStore = &RetryLayerThreadStore{ThreadStore: childStore.Thread(), Root: &newStore} 12541 newStore.TokenStore = &RetryLayerTokenStore{TokenStore: childStore.Token(), Root: &newStore} 12542 newStore.UploadSessionStore = &RetryLayerUploadSessionStore{UploadSessionStore: childStore.UploadSession(), Root: &newStore} 12543 newStore.UserStore = &RetryLayerUserStore{UserStore: childStore.User(), Root: &newStore} 12544 newStore.UserAccessTokenStore = &RetryLayerUserAccessTokenStore{UserAccessTokenStore: childStore.UserAccessToken(), Root: &newStore} 12545 newStore.UserTermsOfServiceStore = &RetryLayerUserTermsOfServiceStore{UserTermsOfServiceStore: childStore.UserTermsOfService(), Root: &newStore} 12546 newStore.WebhookStore = &RetryLayerWebhookStore{WebhookStore: childStore.Webhook(), Root: &newStore} 12547 return &newStore 12548} 12549