1// Copyright (C) MongoDB, Inc. 2017-present.
2//
3// Licensed under the Apache License, Version 2.0 (the "License"); you may
4// not use this file except in compliance with the License. You may obtain
5// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
7package mongo
8
9import (
10	"context"
11
12	"go.mongodb.org/mongo-driver/x/mongo/driver"
13	"go.mongodb.org/mongo-driver/x/mongo/driver/description"
14)
15
16type changeStreamDeployment struct {
17	topologyKind description.TopologyKind
18	server       driver.Server
19	conn         driver.Connection
20}
21
22var _ driver.Deployment = (*changeStreamDeployment)(nil)
23var _ driver.Server = (*changeStreamDeployment)(nil)
24var _ driver.ErrorProcessor = (*changeStreamDeployment)(nil)
25
26func (c *changeStreamDeployment) SelectServer(context.Context, description.ServerSelector) (driver.Server, error) {
27	return c, nil
28}
29
30func (c *changeStreamDeployment) Kind() description.TopologyKind {
31	return c.topologyKind
32}
33
34func (c *changeStreamDeployment) Connection(context.Context) (driver.Connection, error) {
35	return c.conn, nil
36}
37
38func (c *changeStreamDeployment) ProcessError(err error, conn driver.Connection) {
39	ep, ok := c.server.(driver.ErrorProcessor)
40	if !ok {
41		return
42	}
43
44	ep.ProcessError(err, conn)
45}
46