Skip to content

Commit

Permalink
bind grpc sync states to flagd sync states
Browse files Browse the repository at this point in the history
Signed-off-by: Kavindu Dodanduwa <[email protected]>
  • Loading branch information
Kavindu-Dodan committed Jan 24, 2023
1 parent c0b03de commit 521efd6
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 16 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/open-feature/flagd
go 1.19

require (
buf.build/gen/go/kavindudodan/flagd/grpc/go v1.2.0-20230119185434-46a532929237.4
buf.build/gen/go/kavindudodan/flagd/protocolbuffers/go v1.28.1-20230119185434-46a532929237.4
buf.build/gen/go/kavindudodan/flagd/grpc/go v1.2.0-20230123231905-11466466f72d.4
buf.build/gen/go/kavindudodan/flagd/protocolbuffers/go v1.28.1-20230123231905-11466466f72d.4
buf.build/gen/go/open-feature/flagd/bufbuild/connect-go v1.4.1-20221226184428-0dc62ff103b8.1
buf.build/gen/go/open-feature/flagd/grpc/go v1.2.0-20221226184428-0dc62ff103b8.4
buf.build/gen/go/open-feature/flagd/protocolbuffers/go v1.28.1-20221226184428-0dc62ff103b8.4
Expand Down
12 changes: 4 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
buf.build/gen/go/grpc-ecosystem/grpc-gateway/grpc/go v1.2.0-20220906183531-bc28b723cd77.4/go.mod h1:hAKk3I2AivrJgMLXjDGrfzRx2NVWQgEPNfr4Co9DLX4=
buf.build/gen/go/grpc-ecosystem/grpc-gateway/protocolbuffers/go v1.28.1-20220906183531-bc28b723cd77.4/go.mod h1:92ejKVTiuvnKoAtRlpJpIxKfloI935DDqhs0NCRx+KM=
buf.build/gen/go/kavindudodan/flagd/grpc/go v1.2.0-20230119181610-da48a2cc4899.4 h1:4+OZYN1CckvE3FUhICkwKce4CqNrqSF+3lj/qg7jBcA=
buf.build/gen/go/kavindudodan/flagd/grpc/go v1.2.0-20230119181610-da48a2cc4899.4/go.mod h1:VqApiuUWBR0OgYXV2WANGNl1cziMLk/IFuJtcEcBNzQ=
buf.build/gen/go/kavindudodan/flagd/grpc/go v1.2.0-20230119185434-46a532929237.4 h1:IQNSC6162WjVcAaanl6ltVbuWEKO81Q+Rb0RvKbCJK0=
buf.build/gen/go/kavindudodan/flagd/grpc/go v1.2.0-20230119185434-46a532929237.4/go.mod h1:7KypYDNBNnwCC/OHyBLpFRnURona7bfsFlOSnj6YJso=
buf.build/gen/go/kavindudodan/flagd/protocolbuffers/go v1.28.1-20230119181610-da48a2cc4899.4 h1:KoZHvPNbsieBV2wJHv1sI6Hld9Cnx2u0KkY0cfVWj0k=
buf.build/gen/go/kavindudodan/flagd/protocolbuffers/go v1.28.1-20230119181610-da48a2cc4899.4/go.mod h1:jpjQMBqnFcgHMK99ylFu+PhUhA1KD6AC1QSz27yC/1U=
buf.build/gen/go/kavindudodan/flagd/protocolbuffers/go v1.28.1-20230119185434-46a532929237.4 h1:jO34xg8ujvGDu80W5I+U/U1jQHx4LTdcpW1OTPbdJcw=
buf.build/gen/go/kavindudodan/flagd/protocolbuffers/go v1.28.1-20230119185434-46a532929237.4/go.mod h1:jpjQMBqnFcgHMK99ylFu+PhUhA1KD6AC1QSz27yC/1U=
buf.build/gen/go/kavindudodan/flagd/grpc/go v1.2.0-20230123231905-11466466f72d.4 h1:1fQv2ozb/dr74S3CPIGZunSndVzHAPeY5niWnEr0xDg=
buf.build/gen/go/kavindudodan/flagd/grpc/go v1.2.0-20230123231905-11466466f72d.4/go.mod h1:HhDGIP35zh2M82Dx4oIzit5ZEtoOaOyy35dAr/e+Uuo=
buf.build/gen/go/kavindudodan/flagd/protocolbuffers/go v1.28.1-20230123231905-11466466f72d.4 h1:uZNmxfZMZVrfd31Iz4YQsRa6zl4kifKUwRWjtIMz8yI=
buf.build/gen/go/kavindudodan/flagd/protocolbuffers/go v1.28.1-20230123231905-11466466f72d.4/go.mod h1:jpjQMBqnFcgHMK99ylFu+PhUhA1KD6AC1QSz27yC/1U=
buf.build/gen/go/open-feature/flagd/bufbuild/connect-go v1.4.1-20221226184428-0dc62ff103b8.1 h1:KoSPqmHyi3x27tPFLQ994CJjG4qc59v+0gbxY9+VXso=
buf.build/gen/go/open-feature/flagd/bufbuild/connect-go v1.4.1-20221226184428-0dc62ff103b8.1/go.mod h1:68WGv4z/jXuTS3G7FEFQTEw4wiMmulBSX6BlSFX2Xc8=
buf.build/gen/go/open-feature/flagd/grpc/go v1.2.0-20221226184428-0dc62ff103b8.4 h1:9ioWUVmnURL+TX4qVjyzzE3o9Z2ACDGidqtu9dkjmdY=
Expand Down
34 changes: 32 additions & 2 deletions pkg/sync/grpc/grpc_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,42 @@ func (g *Sync) streamHandler(stream servicev1grpc.FlagService_SyncFlagsClient, d
dataSync <- sync.DataSync{
FlagData: data.Flags,
Source: g.URI,
Type: sync.ALL,
}

g.Logger.Debug("received full configuration payload")
continue
case v1.SyncState_SYNC_STATE_ADD:
dataSync <- sync.DataSync{
FlagData: data.Flags,
Source: g.URI,
Type: sync.ADD,
}

g.Logger.Debug("received an add payload")
continue
case v1.SyncState_SYNC_STATE_UPDATE:
dataSync <- sync.DataSync{
FlagData: data.Flags,
Source: g.URI,
Type: sync.UPDATE,
}

g.Logger.Debug("received an update payload")
continue
case v1.SyncState_SYNC_STATE_DELETE:
dataSync <- sync.DataSync{
FlagData: data.Flags,
Source: g.URI,
Type: sync.DELETE,
}

g.Logger.Debug("received a delete payload")
continue
case v1.SyncState_SYNC_STATE_PING:
g.Logger.Info("Received server ping")
g.Logger.Debug("received server ping")
default:
g.Logger.Info(fmt.Sprintf("Receivied unknown state: %s", data.State.String()))
g.Logger.Warn(fmt.Sprintf("receivied unknown state: %s", data.State.String()))
}
}
}
5 changes: 1 addition & 4 deletions schema/sync/v1/flags.proto
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@ enum SyncState{
// Convey a deletion of a flag. Flagd internally removes the flag
SYNC_STATE_DELETE = 4;

// Convey a clean of all flags. Flagd internally removes all flags for this sync provider
SYNC_STATE_CLEAN = 5;

// Optional server ping to check client connectivity. Handling is ignored by flagd and is to merely support live check
SYNC_STATE_PING = 6;
SYNC_STATE_PING = 5;
}

// SyncFlagsResponse is the response contains flags and state
Expand Down

0 comments on commit 521efd6

Please sign in to comment.