You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
615 B

  1. // Copyright 2019 The Xorm Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package xorm
  5. import "context"
  6. // Context sets the context on this session
  7. func (session *Session) Context(ctx context.Context) *Session {
  8. session.ctx = ctx
  9. return session
  10. }
  11. // PingContext test if database is ok
  12. func (session *Session) PingContext(ctx context.Context) error {
  13. if session.isAutoClose {
  14. defer session.Close()
  15. }
  16. session.engine.logger.Infof("PING DATABASE %v", session.engine.DriverName())
  17. return session.DB().PingContext(ctx)
  18. }