Skip to content

Commit 5af7aba

Browse files
committed
updating some chunking logic
1 parent e33a376 commit 5af7aba

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

internal/proto6server/server_readstatebytes.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func readStateBytesErrorDiagnostics(ctx context.Context, diags diag.Diagnostics)
2121
return &tfprotov6.ReadStateBytesStream{
2222
Chunks: func(push func(chunk tfprotov6.ReadStateByteChunk) bool) {
2323
push(tfprotov6.ReadStateByteChunk{
24-
Diagnostics: toproto6.Diagnostics(ctx, diags),
24+
Diagnostics: toproto6.Diagnostics(ctx, diags), // TODO : Think about how we handle diags
2525
})
2626
},
2727
}, nil
@@ -57,16 +57,22 @@ func (s *Server) ReadStateBytes(ctx context.Context, proto6Req *tfprotov6.ReadSt
5757
return readStateBytesErrorDiagnostics(ctx, fwResp.Diagnostics)
5858
}
5959

60+
//var defaultChunkSize int64
61+
//defaultChunkSize = 8 << 20 // 8 MB
62+
6063
protoStream := &tfprotov6.ReadStateBytesStream{
6164
Chunks: func(push func(tfprotov6.ReadStateByteChunk) bool) {
62-
go func() {
63-
s.FrameworkServer.ReadStateBytes(ctx, fwReq, fwResp)
64-
}()
65-
66-
for {
67-
push(toproto6.ReadStateByteChunkType(ctx, fwResp))
68-
return
69-
}
65+
// TODO: Decide on chunk size, get from configure client capabilities?
66+
// Is the provider dev allowed to negotiate and is the chunk size supposed to be global to the provider? (Per 1 state store?) Can we store it on the server?
67+
// Default is 8MB
68+
//for _, chunk := range fwResp.Bytes {
69+
// record where we are
70+
// do math
71+
// look up examples of chunking in go
72+
//}
73+
s.FrameworkServer.ReadStateBytes(ctx, fwReq, fwResp)
74+
push(toproto6.ReadStateByteChunkType(ctx, fwResp))
75+
return
7076
},
7177
}
7278

0 commit comments

Comments
 (0)