本站源代码
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.

29 lines
746B

  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. // +build go1.8
  5. package xorm
  6. import "context"
  7. // Context creates a session with the context
  8. func (engine *Engine) Context(ctx context.Context) *Session {
  9. session := engine.NewSession()
  10. session.isAutoClose = true
  11. return session.Context(ctx)
  12. }
  13. // SetDefaultContext set the default context
  14. func (engine *Engine) SetDefaultContext(ctx context.Context) {
  15. engine.defaultContext = ctx
  16. }
  17. // PingContext tests if database is alive
  18. func (engine *Engine) PingContext(ctx context.Context) error {
  19. session := engine.NewSession()
  20. defer session.Close()
  21. return session.PingContext(ctx)
  22. }
上海开阖软件有限公司 沪ICP备12045867号-1