context.go 625 B

1234567891011121314151617181920212223
  1. package context
  2. import (
  3. "context"
  4. "time"
  5. "go-common/library/net/rpc/liverpc"
  6. )
  7. // WithHeader returns new context with header
  8. // Deprecated: Use HeaderOption instead
  9. func WithHeader(ctx context.Context, header *liverpc.Header) (ret context.Context) {
  10. ret = context.WithValue(ctx, liverpc.KeyHeader, header)
  11. return
  12. }
  13. // WithTimeout set timeout to rpc request
  14. // Notice this is nothing related to to built-in context.WithTimeout
  15. // Deprecated: Use TimeoutOption instead
  16. func WithTimeout(ctx context.Context, time time.Duration) (ret context.Context) {
  17. ret = context.WithValue(ctx, liverpc.KeyTimeout, time)
  18. return
  19. }