-
Notifications
You must be signed in to change notification settings - Fork 116
Conversation
7547ade
to
867938c
Compare
Pull Request Test Coverage Report for Build 1064
💛 - Coveralls |
867938c
to
e04ebde
Compare
@changpingc Do you mind putting the reverts in a separate PR? 😬 |
e04ebde
to
ec2b8f9
Compare
revert landed separately in #167. |
bb9fa86
to
a7bee55
Compare
reactive/rerunner.go
Outdated
} | ||
|
||
type Serializable interface { | ||
proto.Message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we make this a loose coupling by supporting an interface rather than importing proto? I'm open to being overruled here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure it can turn this into Marshal(), Unmarshal() probably
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
sqlgen/reflect.go
Outdated
case float64: | ||
return float64(v) | ||
case time.Time: | ||
return time.Time(v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some types here that we're doing nothing with. Do we need to handle them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this handles all driver.Value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This handles more than driver.Value
- for example, uint32
is not a driver.Value
, only int64
is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opened a separate PR #170
livesql/marshal.go
Outdated
) | ||
|
||
func valueToField(value interface{}) (*thunderpb.Field, error) { | ||
switch column := sqlgen.MakeCanonical(value).(type) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens for custom types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Talked offline. We are going to support it by storing driver.Value. See last commit!
810bd16
to
315c964
Compare
|
||
type Serializable interface { | ||
// proto.Marshaler and proto.Unmarshaler. | ||
Marshal() ([]byte, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could use UnmarshalBinary
/MarshalBinary
and wrap our resource, but I'm cool with this / exposing this interface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't particularly like that.. Feels too clunky to wrap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah but would also be a built-in interface. I'm ok with not wrapping.
|
||
if serializable != nil { | ||
depSet, ok := ctx.Value(dependencySetKey{}).(*dependencySet) | ||
if ok && depSet != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: seems nice to have getter/setter methods on the dependency set rather than handling it here and below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
reactive/util.go
Outdated
) | ||
|
||
func InvalidateAfter(ctx context.Context, d time.Duration) { | ||
r := NewResource() | ||
timer := time.AfterFunc(d, r.Invalidate) | ||
r.Cleanup(func() { timer.Stop() }) | ||
AddDependency(ctx, r, nil) | ||
AddDependency(ctx, r, &thunderpb.ExpirationTime{Time: time.Now().Add(d)}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought - if we have this here, are we still coupling ourselves to proto?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(maybe fine?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes we are.. I feel that's fine.
livesql/live.go
Outdated
@@ -75,7 +76,7 @@ func (t *dbTracker) processBinlog(update *update) { | |||
} | |||
} | |||
|
|||
func (t *dbTracker) registerDependency(ctx context.Context, table string, tester sqlgen.Tester) { | |||
func (t *dbTracker) registerDependency(ctx context.Context, table string, tester sqlgen.Tester, filter sqlgen.Filter) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we have the filter, do we need the tester to be passed in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To build a tester, we need schema object. This change seems like the smallest change I can make
sqlgen/reflect.go
Outdated
case float64: | ||
return float64(v) | ||
case time.Time: | ||
return time.Time(v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This handles more than driver.Value
- for example, uint32
is not a driver.Value
, only int64
is
97c986c
to
e968849
Compare
e968849
to
458de2e
Compare
…ncies There are 2 kinds of dependencies in thunder we want to serialize: reactive.InvalidateAt and livesql.Query. This commit creates protobuf definitions for each type and their gogofast generated files. The serialized dependencies are useful because we want to ship them out of process to an external service.
This commit adds one required nil-able argument that is the serializable form of the dependency. This argument is collected in a dependency set which is accessable via Dependencies(ctx) call.
This commit adds conversion between thunderpb.SQLFilter and sqlgen.Tester. It assumes filter values are driver.Value type for now, and we will relax that condition later.
458de2e
to
3c69e0b
Compare
@berfarah I think this is ready to land! It should not introduce any additional error in existing API. |
@changpingc given the amount of changes here, do you think a second pair of eyes might be useful? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving - though might be good to get some additional eyes from @stephen. The diff count on this PR is deceiving.
livesql/marshal_test.go
Outdated
{ | ||
name: "id int64 ptr to int64", | ||
filter: sqlgen.Filter{ | ||
"id": &one, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nil test case?
b86d5cf
to
49f7dff
Compare
49f7dff
to
e7baaf5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Like the tests
Time = 8; | ||
} | ||
|
||
message Field { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh, think I found what's causing a lot of cloudserver OOMs, I think this field is quite large and taking up much more memory than usual whenever we create a dependency.
Have we thought of using the proto oneof annotation here? Not sure if it actually reduces the allocation in code, just a thought.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd like to ship dependencies out of thunder server process, which allows us to restore a subscription and avoid expensive initial computation when a client reconnects and resumes prior subscriptions. This also enables external dependency invalidator that can make thunder server stateless.