( ctx context.Context, key string, v any, ttl time.Duration, encoder func(any) ([]byte, error), format string, )
| 281 | } |
| 282 | |
| 283 | func (s *SharedState) setEncodedWithContext( |
| 284 | ctx context.Context, |
| 285 | key string, |
| 286 | v any, |
| 287 | ttl time.Duration, |
| 288 | encoder func(any) ([]byte, error), |
| 289 | format string, |
| 290 | ) error { |
| 291 | if err := s.ensureStorage(); err != nil { |
| 292 | return err |
| 293 | } |
| 294 | |
| 295 | storageKey, ok := s.storageKey(key) |
| 296 | if !ok { |
| 297 | return nil |
| 298 | } |
| 299 | |
| 300 | encoded, err := encodeSharedStateValue(v, encoder, format) |
| 301 | if err != nil { |
| 302 | return err |
| 303 | } |
| 304 | |
| 305 | return s.storage.SetWithContext(ctx, storageKey, encoded, ttl) |
| 306 | } |
| 307 | |
| 308 | // getEncodedWithContext returns a defensive copy of the encoded payload after |
| 309 | // decoding it into out, so callers can safely mutate the returned slice. |
no test coverage detected