gitea源码

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright 2023 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package db
  4. import (
  5. "context"
  6. "code.gitea.io/gitea/modules/indexer/internal"
  7. )
  8. var _ internal.Indexer = &Indexer{}
  9. // Indexer represents a basic db indexer implementation
  10. type Indexer struct{}
  11. // Init initializes the indexer
  12. func (i *Indexer) Init(_ context.Context) (bool, error) {
  13. // Return true to indicate that the index was opened/existed.
  14. // So that the indexer will not try to populate the index, the data is already there.
  15. return true, nil
  16. }
  17. // Ping checks if the indexer is available
  18. func (i *Indexer) Ping(_ context.Context) error {
  19. // No need to ping database to check if it is available.
  20. // If the database goes down, Gitea will go down, so nobody will care if the indexer is available.
  21. return nil
  22. }
  23. // Close closes the indexer
  24. func (i *Indexer) Close() {
  25. // nothing to do
  26. }