MCPcopy
hub / github.com/nats-io/nats.go / getJSContextOpts

Function getJSContextOpts

jsm.go:1769–1798  ·  view source on GitHub ↗
(defs *jsOpts, opts ...JSOpt)

Source from the content-addressed store, hash-verified

1767}
1768
1769func getJSContextOpts(defs *jsOpts, opts ...JSOpt) (*jsOpts, context.CancelFunc, error) {
1770 var o jsOpts
1771 for _, opt := range opts {
1772 if err := opt.configureJSContext(&o); err != nil {
1773 return nil, nil, err
1774 }
1775 }
1776
1777 // Check for option collisions. Right now just timeout and context.
1778 if o.ctx != nil && o.wait != 0 {
1779 return nil, nil, ErrContextAndTimeout
1780 }
1781 if o.wait == 0 && o.ctx == nil {
1782 o.wait = defs.wait
1783 }
1784 var cancel context.CancelFunc
1785 if o.ctx == nil && o.wait > 0 {
1786 o.ctx, cancel = context.WithTimeout(context.Background(), o.wait)
1787 }
1788 if o.pre == _EMPTY_ {
1789 o.pre = defs.pre
1790 }
1791 if o.ctx != nil {
1792 // if context does not have a deadline, use timeout from js context
1793 if _, hasDeadline := o.ctx.Deadline(); !hasDeadline {
1794 o.ctx, cancel = context.WithTimeout(o.ctx, defs.wait)
1795 }
1796 }
1797 return &o, cancel, nil
1798}

Callers 15

AccountInfoMethod · 0.85
upsertConsumerMethod · 0.85
DeleteConsumerMethod · 0.85
ConsumerInfoMethod · 0.85
ConsumersMethod · 0.85
ConsumerNamesMethod · 0.85
AddStreamMethod · 0.85
StreamInfoMethod · 0.85
UpdateStreamMethod · 0.85
DeleteStreamMethod · 0.85
getMsgMethod · 0.85
DeleteMsgMethod · 0.85

Calls 1

configureJSContextMethod · 0.65

Tested by

no test coverage detected