initSub function is called on the graphjin struct to initialize a subscription.
(c context.Context, sub *sub)
| 236 | |
| 237 | // initSub function is called on the graphjin struct to initialize a subscription. |
| 238 | func (gj *graphjinEngine) initSub(c context.Context, sub *sub) (err error) { |
| 239 | if err = sub.s.compile(); err != nil { |
| 240 | return |
| 241 | } |
| 242 | |
| 243 | if !gj.prod { |
| 244 | err = gj.saveToAllowList(sub.s.cs.st.qc, sub.s.r.namespace) |
| 245 | if err != nil { |
| 246 | return |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | // Only wrap subscriptions for batching if the dialect supports it |
| 251 | targetCtx := sub.s.getTargetDBCtx() |
| 252 | if len(sub.s.cs.st.md.Params()) != 0 && dialectSupportsSubscriptionBatching(targetCtx.schema.DBType()) { |
| 253 | sub.s.cs.st.sql = renderSubWrap(sub.s.cs.st, targetCtx.schema.DBType()) |
| 254 | } |
| 255 | |
| 256 | go gj.subController(sub) |
| 257 | return |
| 258 | } |
| 259 | |
| 260 | // subController function is called on the graphjin struct to control the subscription. |
| 261 | func (gj *graphjinEngine) subController(sub *sub) { |
no test coverage detected